Hello.
I found this post – https://buddydev.com/support/forums/topic/add-member-name-membername-under-title-on-thumbs/ that seems to ask the exact same question I had.
I have an all-galleries page at theawesomeladiesproject.com/gallery and I would like it to list the @ username of the member underneath the name of the gallery. I tried to put this code into my theme’s functions.php file and it didn’t seem to do anything.
add_action( ‘mpp_after_media_widget_item’, ‘mpp_custom_add_user_link’ );
function mpp_custom_add_user_link() {$user_id = mpp_get_media_creator_id();
$link = sprintf( “%s“, bp_core_get_user_domain( $user_id ), bp_core_get_username( $user_id ) );
echo $link;
}
Did mediapress change on the backend to make this solution not work anymore?
Thanks.
Hi Kristin,
Welcome to BuddyDev.Please use this snippet instead
/** * Add @gallery-creator-username after the title */ function mpp_custom_show_author_user_name_with_gallery() { $gallery = mpp_get_gallery(); if ( ! $gallery ) { return ; } echo '@' . bp_core_get_username( $gallery->user_id ); } add_action( 'mpp_before_gallery_actions', 'mpp_custom_show_author_user_name_with_gallery' );
You may modify it to suit your need.
Hope that helps.
Regards
BrajeshThank you SO much Brajesh. That code works perfectly. I have one additional question.
Members create galleries inside of private groups. The gallery listing page now displays everyone’s username, which is great. But when you click into a gallery, it doesn’t display there name anywhere at the top. Is there a short code snippet that I can add to insert a username display in the gallery title or description?
Thank you!
Kristin
Hi Kristin,
Thank you.
It’s a good idea and will like to have it in the core in future.For now, you may use the following code
/** * Add @gallery-creator-username on single group gallery. */ function mpp_custom_show_author_user_name_with_single_gallery() { if ( ! bp_is_group() ) { return ; } $gallery = mpp_get_gallery(); if ( ! $gallery ) { return ; } echo '@' . bp_core_get_username( $gallery->user_id ); } add_action( 'mpp_before_single_gallery', 'mpp_custom_show_author_user_name_with_single_gallery' );
Hope that helps.
Regards
BrajeshHi Audiomonk,
You can change this lineecho '@' . bp_core_get_username( $gallery->user_id );
to this
printf( '@<a href="%s">%s</a>', bp_core_get_user_domain( $gallery->user_id ), bp_core_get_username( $gallery->user_id ) );
PS: Please open a new topic and link to the existing one in future, that helps us server you better without causing any issue to the older threads. I hope you won’t mind that. It will help us avoid our existing thread users any inconvenience(notification etc).
Thank you
Brajesh
The topic ‘ [Resolved] Adding Usernames to Gallery Listing’ is closed to new replies.