I am trying to add member names to the site wide gallery page associated to buddypress. Currently I have added code to the bp-custom.php file that provides the member name , however the display of the title builds some broken HTML so things do not display properly. This only occurs on items that the member has priviledges to edit.
A picture of the issue can be found here :http://www.itegasus.com/wp-content/downloads/capture.png
Code added to bp-custom.php
function mpp_custom_add_owner_name_gallery_title( $title, $id ) {
$gallery = mpp_get_gallery( $id );if ( ! $gallery ) {
return $title ;
}//do you want to only filter for certain component? uncomment the below lines
/*
if ( ‘sitewide’ !== $gallery->component ) {
return $title;
}
*/
return $title . ‘<span class=”gallery-owner-user”>’ .sprintf( ‘ by: %s’, bp_core_get_userlink( $gallery->user_id ) ) .'</span>’;
}
add_action( ‘mpp_get_gallery_title’, ‘mpp_custom_add_owner_name_gallery_title’, 10, 2 );Hello Ryan,
Thank you for posting, Please try the following code for broken html. It will print the additional title info in a new line.
function buddydev_custom_add_owner_name_gallery_title( $title, $id ) { $gallery = mpp_get_gallery( $id ); if ( ! $gallery ) { return $title ; } //do you want to only filter for certain component? uncomment the below lines /* if ( 'sitewide' !== $gallery->component ) { return $title; } */ return $title . sprintf( '<br><span class="gallery-owner-user"> by: %s</span>', mpp_get_user_link( $gallery->user_id ) ); } add_action( 'mpp_get_gallery_title', 'buddydev_custom_add_owner_name_gallery_title', 10, 2 );
The url you have provided is not reachable for me. But gallery user name still displaying even if user is not logged in.
Thank You
RaviThe updated code did not work, Can I email you a screen shot ? Remember that the issue is only when a logged in users is viewing galleries that they can edit on the site wide gallery page. When a users is not logged in or viewing galleries they don’t have permissions over , the code works perfectly
- This reply was modified 7 years, 6 months ago by Ryan Mckernan.
Hello Ryan,
It seems we are inserting link into another link that is why we have gotten a broken html. Try the following code in your bp-custom.php file
function mpp_custom_add_owner_name_gallery_title( ) { $gallery = mpp_get_gallery(); printf("<br><span>%s</span>", mpp_get_user_link( $gallery->user_id) ); } add_action( 'mpp_before_gallery_actions', 'mpp_custom_add_owner_name_gallery_title');
Thank You
RaviThank you for assisting here Ravi.
Marking the topic as resolved.
Note for visitors: Please do not use the code from the first reply. The last code snippet is the working code.
The topic ‘ [Resolved] Member names on site wide gallery titles’ is closed to new replies.