Log in/Register in Menu

Homepage Community Forums Vintage Theme Support Log in/Register in Menu

Tagged: 

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #19198
    Sandra
    Customer

      Hello
      Is there an easy way to put the login/register meta in the secondary navigation menu? Not versed in PHP but willing to try… Thanks. And what anti-spam plugins would you recommend? Is captcha good enough?

      #19199
      Wes
      Moderator

        Try this code in your functions.php file –

        
        add_filter( 'wp_nav_menu_items', 'sp_add_loginout_link', 10, 2 );
        function sp_add_loginout_link( $items, $args ) {
        	// Change 'primary' to 'secondary' to put the login link in your secondary nav bar
        	if ( $args->theme_location != 'primary' )
        		return $items;
        	if ( is_user_logged_in() ) {
        		$items .= '<li class="menu-item"><a href="'. wp_logout_url() .'">Log Out</a></li>';
        	} else {
        		$items .= '<li class="menu-item"><a href="'. site_url('wp-login.php') .'">Log In</a></li>';
        	}
        	return $items;
        }

        This works for the Primary Menu so you’ll have to make adjustments to the code in order for it to work with the Secondary Menu.

        Source – https://gist.github.com/nickcernis/02086c75ee9aa19447e0

        I tested on a regular Primary Menu and it worked perfectly for “Logged in” and “Out” users. You can test to see if your adjustments work for the Secondary Menus as well.

        Currently, I’m not using any Anti Spam plugins so I’m not sure which one would be best at the moment. I’d check the reviews to see what other users are prefer.

        #19203
        Sandra
        Customer

          Thanks! That worked out nicely… Do you know how I can customise the dashboard? Right now the Askimet and spam blocks are showing up which i rather not…

          #19237
          Wes
          Moderator

            I’ve never done it before, but I did see there are some plugins out there that allow you to customize it. I just Googled “How to customize Dashboard” and a few showed up.

          Viewing 4 posts - 1 through 4 (of 4 total)
          • You must be logged in to reply to this topic.