Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #347894

    Hi –

    At the top you’ll see a Login | Register links – how can I make it so that when a user logs in (using Member Press plugin currently) that a ‘Log Out’ link will appear replacing the Login link?

    So the link essentially would be dynamic.

    I am comfortable editing some code, but would not know where to begin.

    Thanks for your help.

    #348183

    Hey cmconline247!

    This would take a lot of time and code and would have to be considered custom work. It would be best to contact the plugin authors as they may have a solution already made.

    Best regards,
    Elliott

    #353536

    Well you can fudge it, hack it, or whatever you want to call it.

    I need a login on my site so using plugin WP-Members, I set the site up with non dynamic menus (as they are) and then showed the source html in the browser

    I grabbed the source from
    <div id='wrap_all'>
    to
    </header>
    which includes my menus etc.

    Paste this in to your enfold theme header.php overwriting the code between the above mention html tags. (Backup header.php first)

    Then I added a function to the header.php (just below wp_head();) to see if i was logged in and return a html string with the correct classes, ids etc. Copied from the code just copied. I’ve only shown the login/logout menu not all the others i have.

    function my_login_status()
    {
    global $user_login;
    $logout = get_bloginfo('url')."/?a=logout";
    $login = get_bloginfo('url')."/members-area/";
    
    if (is_user_logged_in()) {
    
    $wpmem_login_status = "
    <li id='menu-item-83' class='menu-item menu-item-type-post_type menu-item-object-page menu-item-top-level menu-item-top-level-3'>
    <a href='http://mysite.co.uk/login/?a=logout'><span class='avia-bullet'></span><span class='avia-menu-text'>Logout</span>
    <span class='avia-menu-fx'><span class='avia-arrow-wrap'><span class='avia-arrow'></span></span></span></a></li>
    ";
    
    } else {
    
    $wpmem_login_status = "
    <li id='menu-item-83' class='menu-item menu-item-type-post_type menu-item-object-page menu-item-top-level menu-item-top-level-3'>
    <a href='http://mysite.co.uk/login/'><span class='avia-bullet'></span><span class='avia-menu-text'>Login</span>
    <span class='avia-menu-fx'><span class='avia-arrow-wrap'><span class='avia-arrow'></span></span></span></a></li>
    ";
    }

    Then where the actual menus appear in the html you just pasted in replace that with
    <?php echo my_login_status(); ?>

    So in essence you are hard coding your menus in the header. If you change a menu in the backend it wont have any effect.

    Yeah its dirty, yeah its not a great solution, but hey, I cant believe login isnt already a part of such a great theme.

    Cheers

    n.b. if you require logout check then change you function href to have an extra / on the end
    http://mysite.co.uk/login/?a=logout/

    #bodge

    #353903

    Hey!

    Thanks for posting your solution darrenrhymer.

    Best regards,
    Elliott

    #354043

    Hopefully my suggestion is understandable and will help someone.

Viewing 5 posts - 1 through 5 (of 5 total)
  • The topic ‘Login/Logout in Top Menu’ is closed to new replies.