Show quantity of media files in buddypress users page


#1

How to show quantity of media files in buddypress users page?
Forexample here http://fotofotografov.ru/photographers/ it should look like:
-User Name
-Activity 1 hour ago
-Media 16


#2

@supergrower, Yeah, you can do that by using following code, even in respect of privacy.

$media_nav = new RTMediaNav(false); $user_id = // user id here $user_media_counts = $media_nav->get_counts($user_id); $user_counts = $media_nav->actual_counts($user_id);

$user_counts will hold the user media counts.


#3

Sorry, may be you help me.. I think that I should insert some code in members-loop.php May be you tell me what exactly code it is? Or tell me in what file I should insert your code above. Thanks.


#4

Have you overridden BuddyPress templates?

If yes, than you need to add this code in your theme's members-loop.php file, if not, you need to override BuddyPress templates in your theme and than add this code in members-loop.php file.

Do not change plugins file directly.

Also, hold this code inside class_exist condition for RTMediaNav class so it won't break anything if you disable rtMedia.


#5

Yes, I have overridden BuddyPress template. I have add this code in my theme’s members-loop.php file. It doesn't work. May be I insert it in not right place. Also I dont know what is "user id" in this file. Can you help me? PS: thanks for your help.


#6

@supergrower add this code in to your theme's functions.php file.

add_action( 'bp_directory_members_item', 'rtm_get_user_media_count' ); function rtm_get_user_media_count( ){ global $members_template; if( class_exists( 'RTMediaNav' ) ){ $media_nav = new RTMediaNav(false); if( isset( $members_template->member->ID )){ $user_id = $members_template->member->ID; } $user_media_counts = $media_nav->get_counts($user_id); $user_counts = $media_nav->actual_counts($user_id); echo 'Media: '.$user_counts['total']['all']; } }

This will display media of respective members.


#7

Thank you!


#8