BuddyDev

Search

Displaying title and user on shortcode pages

  • Keymaster
    (BuddyDev Team)
    Posts: 24593
    Brajesh Singh on #8658

    Hi Ryan,
    Than you for posting.

    Are you looking it for shortcode or the directory page?

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

    I just realized that my question my not be related to the original post. I am looking for a way to add the members name to the site wide photo gallery. It currently only shows the Album title.

  • Keymaster
    (BuddyDev Team)
    Posts: 24593
    Brajesh Singh on #8683

    Thank you Ryan.

    Please let me check and I will post back.

    Regards
    Brajesh

  • Keymaster
    (BuddyDev Team)
    Posts: 24593
    Brajesh Singh on #8684

    Hi Ryan,
    The following code will add the gallery creator’s name in the gallery title at all places

    
    
    /**
     * Injects gallery owner's name in the gallery title
     *
     * @param $title
     * @param $id
     *
     * @return string
     */
    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 );
    
    

    Hope that helps.

    Regards
    Brajesh

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

    Thank you , where would I add this code to ?

  • Keymaster
    (BuddyDev Team)
    Posts: 24593
    Brajesh Singh on #8686

    You can put it in your theme’s functions.php or in the bp-custom.php in the plugin’s directory

    https://buddydev.com/docs/guides/guides/buddypress-guides/what-is-bp-custom-php/

    Regards
    Brajesh

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

    ok, I added it to a bp-custom.php but did not work as intended. do you want me to create a separate thread for this ?

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

    Nevermind, I didn’t have the bp-custom.php in the correct location. Eveything is working correctly now. Thank you !

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

    Well I spoke to soon, look like when I user Is looking at there own gallery is messes up the html for upload , delete.

    Wall photo Gallery by: Ryan Mckernan
    view by: Ryan Mckernan”>upload by: Ryan Mckernan” class=”confirm mpp-confirm mpp-delete mpp-delete-gallery”>delete

    <div class=”mpp-item-actions mpp-gallery-actions”>
    view by: Ryan Mckernan“>upload by: Ryan Mckernan” class=”confirm mpp-confirm mpp-delete mpp-delete-gallery”>delete </div>

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

    Well I spoke to soon, looks like when A user Is looking at there own gallery it messes up the html for upload , delete.

    Wall photo Gallery by: Ryan Mckernan
    view by: Ryan Mckernan”>upload by: Ryan Mckernan” class=”confirm mpp-confirm mpp-delete mpp-delete-gallery”>delete

    <div class=”mpp-item-actions mpp-gallery-actions”>
    view by: Ryan Mckernan“>upload by: Ryan Mckernan” class=”confirm mpp-confirm mpp-delete mpp-delete-gallery”>delete </div>

The topic ‘Displaying title and user on shortcode pages’ is closed to new replies.

This topic is: not resolved