BuddyDev

Search

[Resolved] Member names on site wide gallery titles

  • Participant
    Level: Enlightened
    Posts: 22
    Ryan Mckernan on #8939

    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 );

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 3115
    Ravi on #8946

    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
    Ravi

  • Participant
    Level: Enlightened
    Posts: 22
    Ryan Mckernan on #8948
    This reply has been marked as private.
  • Participant
    Level: Enlightened
    Posts: 22
    Ryan Mckernan on #8949

    The 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

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 3115
    Ravi on #8951
    This reply has been marked as private.
  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 3115
    Ravi on #8952

    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
    Ravi

  • Participant
    Level: Enlightened
    Posts: 22
    Ryan Mckernan on #8955

    worked perfectly

  • Keymaster
    (BuddyDev Team)
    Posts: 24623
    Brajesh Singh on #8959

    Thank 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.

This topic is: resolved