Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Get randome image in member's loop
<?php
// Add this function to theme's functions.php
/**
* Show randome album image in member's loop.
*/
function rtmedia_members_gallery() {
global $wpdb;
if ( function_exists( 'bp_get_member_user_id' ) ) {
// Get member's ID.
$member_id = bp_get_member_user_id();
$user_query = "SELECT * FROM `{$wpdb->prefix}rt_rtm_media` WHERE `media_author` = '{$member_id}' AND `media_type` = 'photo' ORDER BY rand() LIMIT 1";
$thumb_detail = $wpdb->get_row( $user_query );
$members_media_image = wp_get_attachment_image( $thumb_detail->media_id, 'thumbnail' );
if ( ! empty( $members_media_image ) ) {
echo $members_media_image;
}
}
}
add_action( 'bp_directory_members_actions', 'rtmedia_members_gallery' );
?>
// Add this to custom css ( rtMedia->settings->Custom CSS )
#buddypress ul.item-list li .item {
float: left !important;
width: 55% !important;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment