Skip to:
Content
Pages
Categories
Search
Top
Bottom

Conditional for a users profile page only (users homepage)


  • AM77
    Participant

    @andy277

    Is there a conditional for a users profile page only. When I say profile page I’m referring to the users homepage not the profile tab – mysite.com/members/example-user

    I’ve looked at the BuddypPress template tags, but none work for it.

    Currently, my default component and action for my profile page is activity>personal, so this will work:

    if ( bp_is_activity_component() && bp_is_current_action('just-me') ) {
       
    }

    But I might use a plugin for a new custom user profile page so I need a conditional for the users profile page rather than the default component and action.

    Any help apreciated

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

  • Henry Wright
    Moderator

    @henrywright

    bp_is_user_profile() will return true if the current page is a profile page. Does that help?


    AM77
    Participant

    @andy277

    Thanks for your help.

    That’s for the profile component:

    mysite.com/members/example-user/profile/
    mysite.com/members/example-user/profile/edit/
    mysite.com/members/example-user/profile/change-avatar/

    I’m looking for a conditional for only:

    mysite.com/members/example-user/

    I call mysite.com/members/example-user/ the main profile page as that is what I’ve seen others call it but I think I’ll call it the users homepage from now on. So yeah I’m basically looking for the conditional for mysite.com/members/example-user/


    Henry Wright
    Moderator

    @henrywright

    bp_is_user() might be what you need. It will return true when there is a displayed user. For example, all of the following would return true:

    example.com/members/user
    example.com/members/user/profile
    example.com/members/user/friends

    Henry Wright
    Moderator

    @henrywright

    If not, then take a look here. That’s everything that’s currently available that relates to user pages.


    AM77
    Participant

    @andy277

    I don’t think there is a conditional for it as I’ve looked everywhere for it.

    bp_is_user() won’t work because I need it only for:
    example.com/members/user

    Not
    example.com/members/user and example.com/members/user/profiles and example.com/members/user/friends etc.

    So far it appears there is no conditional for it.


    Henry Wright
    Moderator

    @henrywright

    So far it appears there is no conditional for it.

    In that case you’ll need to use the && operator to exclude the pages you don’t want.


    Fiush
    Participant

    @fiush

    Hi Henry, I think he is referring to load profiles page conditionally.
    Ex: if a user choose “male ” as option while sign-up, or else “female ” based on xprofiles (may be, but for example I’m informing ).
    Then based on those conditions, he wants to load specific home/profile template ( each template is different).
    So if one can use if & else statements to load different templates from BP home page template


    Henry Wright
    Moderator

    @henrywright

    Hi @fiush,

    I’m not sure that is what @andy277 wants. @andy277 can you confirm?


    Fiush
    Participant

    @fiush

    You can achieve this by using, ‘if ‘ and ‘else ‘ statement.

    You can do that in theme/members/single/home.php

    You can modify the code,

    <?php locate_template( array( ‘members/single/member-header.php’ ), true ); ?>

    To,

    1) if user have profile field ‘male ‘ then
    <?php locate_template( array( ‘members/single/member-header-male.php’ ), true ); ?>

    Else (eg: based on profile field selected,)

    2) <?php locate_template( array( ‘members/single/member-header-female.php’ ), true ); ?>

    Make sure to create two different templates in the same directory.

    If this not the case, Henry can help you


    AM77
    Participant

    @andy277

    I haven’t tested this code, got it from another site, lets say you wanted to display a link when you are viewing a users page:

    global $bp;
    if ( bp_is_user() ) {
       ?><a href="<?php echo $bp->displayed_user->domain; ?>" >This links back to users homepage</a> <?php
    }

    how would you write this so this code doesn’t show on the users homepage? as we don’t want this link to show when we are already on the homepage

    global $bp;
    if ( bp_is_user() && ! the_conditional_for_a_users_homepage() ) {
       ?><a href="<?php echo $bp->displayed_user->domain; ?>" >This links back to users homepage</a> <?php
    }

    sammjv
    Participant

    @sammjv

    My coding skills are very less but want exactly what @Flush said I saw the code in bp but I don’t now what exact code to use to modify the above said piece of code.
    Will you guys provide the conditional statement to load two files based on created profile fields.

    I don’t know weather @andy277 also wants same.


    Fiush
    Participant

    @fiush

    @andy277 your questions are so confusing.
    I don’t think any one can understand what exactly you want to achieve.please be clear on the topic.


    AM77
    Participant

    @andy277

    I Apologize for not being clear.

    If I asked someone for the conditional for the homepage on a wordpress site, they’ll say home_url

    If on a multisite and I wanted a conditional for both the multisite homepage and a user homepage, the’ll say network_home_url for the multisite homepage and home_url for a users homepage.

    What is the homepage for a users homepage on buddypress? When I say users homepage, I’m talking about the page that displays as soon as you click on a member in the members directory, so for member chris the homepage is on mysite.com/members/chris

    What is the conditional for when the page is on a users homepage like mysite.com/members/chris

    I’m saying I don’t think there is a conditional for it, bp_is_user displays on all users pages but I just want it for the users homepage.


    AM77
    Participant

    @andy277

    So this will probably be the last time I ask a support question on my mobile.

    I just wanted to know if a conditional for the URL mysite.com/members/user1 exists but I don’t think it does.

    By the way, what do you call this page anyway:

    mysite.com/members/user1

    I’ve been calling it users homepage


    Fiush
    Participant

    @fiush

    To achieve this, just use a plugin for login or sign-up, and their you will get the options to set redirect url. So that after log in and log out you can re direct the user to his/her profile and to direct home page after sign out.


    Fiush
    Participant

    @fiush

    Sorry @sammjv, may be any moderator will help you, who has better knowledge of bp moderation.
    Ask @Henry Wright for further development.

Viewing 16 replies - 1 through 16 (of 16 total)
  • The topic ‘Conditional for a users profile page only (users homepage)’ is closed to new replies.
Skip to toolbar