BuddyDev

Search

[Resolved] Add Extra links to BuddyPress User Profile –> just show to profile owner

  • Participant
    Level: Initiated
    Posts: 5
    Alessio on #10387

    Hey there,

    I asked a question in your blog post “Add Extra links to BuddyPress User Profile | https://buddydev.com/buddypress/add-extra-links-to-buddypress-user-profile-menu-buddypress-group-menu/” about how to make the added links just visible for the profile owner.

    Brajesh kindly answered with this solution:

    if ( ! bp_is_my_profile() ) {
    return ;
    }

    But where do I have to put this in the code?

    My code was:

    add_action( ‘bp_member_options_nav’, ‘buddydev_add_profile_extra_custom_links’ );

    function buddydev_add_profile_extra_custom_links() {

    ?>

    Google
    BuddyDev 🙂

    <?php
    }

    Could someone help me with this? I don’t know the syntax how to add this if condition.

    Thanks!!

  • Keymaster
    (BuddyDev Team)
    Posts: 24583
    Brajesh Singh on #10388

    Hi Alessio,
    Thank you for posting here.

    Please use the follwing code

    
    
    /**
     * Show links to the profile owner
     */
    function buddydev_add_profile_extra_custom_links() {
    	// show only if my profile.
    	if ( ! bp_is_my_profile() ) {
    		return;
    	}
    
    	?>
    
    	<a href="http://google.com" rel="nofollow">Google</a>
    	<a href="https://buddydev.com">BuddyDev :)</a>
    
    	<?php
    }
    
    add_action( 'bp_member_options_nav', 'buddydev_add_profile_extra_custom_links' );
    
    

    Hope this helps.
    Regards
    Brajesh

  • Participant
    Level: Initiated
    Posts: 5
    Alessio on #10389

    It worked perfectly! I just had to add the “< li >” tags.

    Thanks for your help!!

    • This reply was modified 7 years, 2 months ago by Alessio.
    • This reply was modified 7 years, 2 months ago by Alessio.
  • Keymaster
    (BuddyDev Team)
    Posts: 24583
    Brajesh Singh on #10392

    You are welcome. yes, you are right about wrapping the link in li tags.

    Glad it is resolved.

    Regards
    Brajesh

The topic ‘ [Resolved] Add Extra links to BuddyPress User Profile –> just show to profile owner’ is closed to new replies.

This topic is: resolved