Skip to:

Determine if page is the main members page, not 'profile'

  • ch1n3s3b0y



    I need the main members page to be the profile page, e.g. I need /members/exampleuser/ to be the actual profile page, not /members/exampleuser/profile.

    To do this, I thought I could just use bp_is_user() to determine that it is the main user page and then insert the profile template. However this doesn’t seem to work. This just seems to check if it is ANY user page, including edit etc.

    I also, don’t want it to let me know if it is the logged-in users home member page. It needs to be if it is any member’s ‘home’ user page.

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

  • ch1n3s3b0y


    Ok, I have sort of figured this out myself, however it feels a little ‘hacky’ as I would have thought BP has a built in function to determine if it is the ‘main page’ of a users profile.

    This is what I added to home.php, where the if else statements for the different template parts are:

    $userID = bp_displayed_user_id();
    $userURL = bp_core_get_username($userID);
    $testURL = $_SERVER['SERVER_NAME'].'/members/'. $userURL . '/';
    //echo($host); /*Just to check*/
    //echo($testURL); /*Just to check*/
    if ( $host == $testURL ) :
    bp_get_template_part( 'members/single/profile/profile-loop' );

    This appears to accurately check if you are on the ‘main’ user page and then displays the profile template.

    If there is a better way then please do let me know.

    🙂 did you check the BP codex before embarking on above?

    The docs is first port of call, we attempt to document as much as possible there on an ongoing basis, some pages are undergoing re-freshing & updating but still provide useful reference like this page:

    Template Tag Reference

    Where you might try bp_is_directory()

    Or scan through bp-core-template.php in the core files where you’ll find reference to: bp_is_members_directory()

    which actually is a very simple check to see if !bp_is_user() && bp_is_members_component() the difference remaining can only be the members main directory.

    Generally BP is well specified for template tags and ‘is’ function checks.



    @hnla – Hi Hugo. Thanks for answering. I think my question may not be clear and some terms are getting confused with others. The tags you describe above are for the members directory aren’t they?

    For example, this would be located at This is not the page I need to check for. I need to check for the main page of a members profile, e.g. All of the other pages seem to have a tag to check for them, except this page.

    Also, this needs to be for the main page of any profile, not just the logged in user, e.g. bp_is_home.

    Ah oh, slightly harder possibly, try checking through the available tags though, something is probably achievable that is simpler than your initial attempt.



    @hnla – yes it’s more complicated than it first seems. What I have works, just doubt it is the most efficient. Hopefully someone that has had to deal with this has a better solution that mine.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Determine if page is the main members page, not 'profile'’ is closed to new replies.
Skip to toolbar