WordPress.org

Support

Support » Plugins and Hacks » Login Logout Menu » [Resolved] [Plugin: BAW Login Logout Menu] Suggestion: hide login/out links when irrelevent

[Resolved] [Plugin: BAW Login Logout Menu] Suggestion: hide login/out links when irrelevent

  • I want to to put my login and log out links in different places in my menu. For example, when logged out, a “login” menu is displayed. When logged in, an “account” menu item is displayed, and “log out” is a submenu item of that.

    What I’m suggesting, is an option to hide the login or logout menu item based on whichever is unnecessary.

    http://wordpress.org/extend/plugins/baw-login-logout-menu/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Julio Potier

    @juliobox

    You can do this by adding CSS classes in your menu entry. Then, based on whichever is unnecessary, you add a CSS inline style with /STYLE tag and add a my-class{ display:none; }
    What do you think abut that

    I worry about trusting generic ID’s like “#menu-item-667”. But I went for it this time 🙂

    thanks

    professor99

    @professor99

    An idea along this line is to put the following code into your functions.php file.

    <?php
    /*
     * Suppress/show items if user not logged in.
     *
     * class login: Display if user logged in.
     * class logout: Display if user logged out
     */
    
    add_filter(  'wp_head' , 'loginout_css' );
    
    function loginout_css() {
    	if (is_user_logged_in()){
    ?>
    		<style type="text/css" media="screen">
    			.logout{
    				display:none;
    			}
    		</style>
    	<?php } else { ?>
    		<style type="text/css" media="screen">
    			.login{
    				display:none;
    			}
    		</style>
    <?php
    	}
     }
    ?>

    Then just add the login/logout class to any html tag you want displayed/suppressed for logged in/out users.

    In the case of menu items first proceed to the menu admin screen. Select screen options (window top right) and make sure the ‘CSS Classes’ checkbox item is checked.

    Then on the relevant menu bar click on the down arrow on it’s right to display it’s options. Then add ‘login’ or ‘logout’ to the ‘CSS Classes (optional)’ item.

    Works a dream!

    Cheers
    TheProfessor

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Resolved] [Plugin: BAW Login Logout Menu] Suggestion: hide login/out links when irrelevent’ is closed to new replies.
Skip to toolbar