[resolved] Detecting If User Is Logged In (2 posts)

  1. Odai Athamneh
    Posted 2 years ago #

    I'm working on a theme that will have a login link in the header. So if you're logged in, it just says logout, but if you're not logged in, it also displays a register link.

    Below is the simple php switch I'm using to do this. It works fine for logged in users, but for guests, it's only showing a login link (no register link):

    <div id="login-link" class="masthead-element">
    			if ( is_user_logged_in() ) {
        				echo wp_loginout();
    			} else {
        				echo wp_register(), wp_loginout();

    So I'm guessing that, for whatever reason, it's not getting to the else part, and all visitors are seeing the first argument. But I can't find any reason for that to happen.

    I'm running this theme in a multi-site install, on a sub-domain of my main site, if that's relevant.

  2. Odai Athamneh
    Posted 2 years ago #

    Found the issue, turns out the Register link isn't displayed if registration is disabled.

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.