Skip to:
Content
Pages
Categories
Search
Top
Bottom

Detect if user is viewing their own profile?


  • katemgilbert
    Participant

    @katemgilbert

    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?

Viewing 2 replies - 1 through 2 (of 2 total)

  • katemgilbert
    Participant

    @katemgilbert

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

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


    r-a-y
    Keymaster

    @r-a-y

    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!’;

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Detect if user is viewing their own profile?’ is closed to new replies.
Skip to toolbar