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

    Thread Starter Gabe462

    (@gabe462)

    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 ‘[Plugin: BAW Login Logout Menu] Suggestion: hide login/out links when irrelevent’ is closed to new replies.