Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: Can someone tell me the if tags for not logged in users please?


Boone Gorges
Keymaster

@boonebgorges

This is getting a bit complicated, and will involve calling the $bp global variable, so it’s best to move it to a self-contained function that will then be called in your templates.

Put the following in your child theme’s functions.php file (create one if it doesn’t exist, making sure you have the opening and closing <?php and ?> tags).

function jeff_signup_profile_link() {
global $bp;

if (!is_user_logged_in() ) {
echo '<li ';
if ( bp_is_page( BP_REGISTER_SLUG ) )
echo 'class="selected"';
echo '><a href="register">Sign up!</a></li>';
} else {
echo '<li ';
if ( $bp->loggedin_user->domain == $bp->displayed_user->domain )
echo 'class="selected"';
echo '><a href="';
echo $bp->loggedin_user->domain;
echo '">My Profile</a></li>';
}
}

Then, in your template file where you’d like the link to appear, use

<?php jeff_signup_profile_link() ?>

Skip to toolbar