Minor Issue with Registration/Login/Logout

This topic contains 4 replies, has 2 voices, and was last updated by  Simone 9 years ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
  • Author
    Posts
  • #37141

    thebirdiemachine
    Expired Member
    Post count: 246

    Hi,

    Originally I was using Theme My Login for registration and login/out because it had the Captcha feature. I got to a point that with all the updates of WP, my theme & GD it no longer worked so I deleted it and am using the GD login/logout (now that it has the Captcha) – however I am not using the widget.

    In my “topbar”I have links for Register, Login & Logout. Everything seems to be working OK except the the “Logout” link shows at all times and it really should ONLY just show/appear when a user is logged in.

    Advise on how to fix this? Site is http://www.muttmaps.com

    Thanks
    Stacey

    #37144

    Simone
    Expired Member
    Post count: 3515

    Hi Stacey, how have you added that links in the topbar? You said it is not a widget (and not a GD widget either) so it must be a manual url added by you or the theme.

    #37227

    thebirdiemachine
    Expired Member
    Post count: 246

    Hi Simone,

    Here is how I added the link on the TopBar (Red topbar with White Font)

    HTML in the “TopBar Content Box” in the Customize Header Section for the theme (X-Theme):

    Our Blog: The Hydrant |
    Log In
    Register
    Log Out

    Here is what I have in the Custom CSS: (Can’t remember why I have all this – if it is right, wrong, or redundant)

    .wp-login-url:before,
    .wp-register-url:before,
    .wp-logout-url:before {
    content: ‘ | ‘;
    }

    .wp-logout-url,
    .logged-in .wp-login-url,
    .logged-in .wp-register-url {
    display: none !important;
    }

    .logged-in .wp-logout-url {
    display: inline !important;
    }

    Hope this is what you were asking me for.

    Cheers,
    Stacey

    #37250

    thebirdiemachine
    Expired Member
    Post count: 246

    Oops I see that the html got converted to links sorry about that here is the html:

    
    
    <a href="/blog-the-hydrant/">Our Blog: The Hydrant</a> |
    <a href="/?geodir_signup=true&page1=sign_up/" class="wp-login-url">Log In</a> 
    <a href="/?geodir_signup=true&page1=sign_up/" class="wp-register-url">Register</a> 
    <a href="/wp-logout.php?action=logout&redirect_to=http://www.muttmaps.com/" class="/wp-logout-url">Log Out</a>
    #37308

    Simone
    Expired Member
    Post count: 3515

    That’s the point, you have written the code in a way that it cannot be excluded if an user is logged in/not logged in, it just shows it no matter what.

    You should use something like

    
    
     <?php if ( is_user_logged_in() ) {
    
    ?>
    <a href="/blog-the-hydrant/">Our Blog: The Hydrant</a> |
    <a href="/wp-logout.php?action=logout&redirect_to=http://www.muttmaps.com/" class="/wp-logout-url">Log Out</a>
    
    <?php } 
    
     else {
    ?>
    <a href="/blog-the-hydrant/">Our Blog: The Hydrant</a> |
    <a href="/?geodir_signup=true&page1=sign_up/" class="wp-login-url">Log In</a> 
    <a href="/?geodir_signup=true&page1=sign_up/" class="wp-register-url">Register</a> 
    <?php
    }
    ?>
Viewing 5 posts - 1 through 5 (of 5 total)

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket