Group Mods

  • Profile picture of @mercime
  • Profile picture of r-a-y
  • Profile picture of Hugo

Detect if user is viewing their own profile? (3 posts)

Started 10 months, 3 weeks ago by: katemgilbert

  • Profile picture of katemgilbert katemgilbert said 10 months, 3 weeks ago:

    I want to show text in the member header that welcomes the user if they’re viewing their own profile. So when looking at their own profile, it says “Welcome, [name]!”, and if they view another user’s profile, it just says [name] in the same spot.

    I have it so the system checks if the user is logged in, but I need to take it one step further to check if the profile matches the logged in user.

    Here’s what I have now (php calls removed because I can’t get backticks to work):

    if ( is_user_logged_in() ) :
    Welcome,
    endif;
    bp_displayed_user_fullname()

    How can I change that first if statement to check the logged in user’s identity against the active profile page?

  • Profile picture of katemgilbert katemgilbert said 10 months, 3 weeks ago:

    RESOLVED. Here’s the updated code if others are looking for a similar solution:

    if ( bp_is_home() ) :
    Welcome,
    endif;
    bp_displayed_user_fullname()

  • Profile picture of r-a-y r-a-y said 10 months, 3 weeks ago:

    bp_is_my_profile() is the function you’re looking for.

    if ( bp_is_my_profile() )
    echo ‘hello logged in user who is looking at their own profile!’;