Search code examples
phpwordpressbuddypress

How to display element only on the page of the loggedin user of Buddypress?


I have a Wordpress website running Buddypres. I want to add a link [EDIT] for the user to edit his profile.

But when I put my code, it appears not only on the profile of the logged in user but when he visit the profile of other, it appears too !

Is there a way to display the link only on the logged in user's profile ?

Here is the code I try to show :

<a href="<?php echo bp_loggedin_user_domain(); ?>profile/edit">[EDIT]</a>

Solution

  • Try:

    <?php if ( bp_is_my_profile() ) : ?>
       <a href="<?php echo bp_loggedin_user_domain(); ?>profile/edit">[EDIT]</a>
    <?php endif; ?>