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";

}
link|improve this question

75% accept rate
feedback

1 Answer

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

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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