Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I would like to create a function to determine if a user is logged in or logged out. If the user is logged in I would like the navigation menu text to say "My Account" (this is what it currently displays because 'My Account' is the page name.) If the user is logged out, I would like the navigation menu text to read "Login".

This is my idea so far....

if (is_user_logged_in()) {
    $my_account = "My Account";
    return is_page($my_account);
} else {
    $login = "Login/Sign Up";
    return is_page($my_account) = "$login";

}
share|improve this question

1 Answer 1

I'm not really sure what you're trying to achieve with the is_page parts - maybe I'm missing something - but what if you'd just write:

if (is_user_logged_in()) {
    $my_account = "My Account";
    echo ($my_account);
} else {
    $login = "Login/Sign Up";
    echo ($login);
}

return just returns the variables for use in your code, echo prints them to the HTML

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.