0

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

}
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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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