• Resolved Martijn

    (@ximie90)


    Hi,

    I’ve got another problem, something I ran into.
    When adding some extra custom menu’s in the footer widget area I noticed the logout link showing, when loggin out the login and register link showed up in the new menu.

    Is there a way to limit this function to only the main menu?

    I could work around it and make the custom menu without using the menu feature of wordpress, but this would defeat the purpose of using WP in the first place if I still have to code in all the menu etc.

    Kind regards,

    Martijn

    https://wordpress.org/plugins/bbp-style-pack/

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author Robin W

    (@robin-w)

    Untested (I am overworked at the moment), but in

    wp-content/plugins/bbp-style-pack/includes/function.php

    try changing lines 88 – 111 to

    /**********BSP LOGIN*******************/
    
    /**********adds login/logout to menu*******************/
    if ($bsp_login['add_login'] == true  ) {
    add_filter( 'wp_nav_menu_items', 'bsp_nav_menu_login_link', 10, 2 );
    }
    
    function bsp_nav_menu_login_link($menu, $args) {
    if( $args->theme_location == 'primary' ) {
    
    	global $bsp_login ;
        if ($bsp_login['only_bbpress'] == true ) {
        if(is_bbpress()) {
        $loginlink = bsp_login() ;
        }
        else {
        $loginlink="" ;
        }
    	}
    	else {
    	$loginlink = bsp_login();
    	}
            $menu = $menu . $loginlink ;
    		}
            return $menu;
    
    }

    If that works, come back and I’ll give you then register part.

    If it doesn’t, then I got the code from

    http://wordpress.stackexchange.com/questions/2143/customizing-only-a-specific-menu-using-the-wp-nav-menu-items-hook

    so take a look at that

    Hope you can work it out !

    Let me know either way !

    Thread Starter Martijn

    (@ximie90)

    Oh, this removed all the logout buttons, also from the main menu

    Thread Starter Martijn

    (@ximie90)

    I’ll have a look later on, busy till later next week so no rush.

    Thread Starter Martijn

    (@ximie90)

    I noticed the theme location primary in the code, After checking I had to change it as the Theme had changed it for to something else for the primary (Don’t know why)..but this solved the problem, Thanks

    Plugin Author Robin W

    (@robin-w)

    Great – glad you’re fixed !

    Thread Starter Martijn

    (@ximie90)

    Could you point out what to do for the register link, I could’t figure that one out, probebly the same concept, but I couldn’t get is to work.

    Kind regards,

    Martijn

    Plugin Author Robin W

    (@robin-w)

    Try

    if ($bsp_login['register'] == true  ) {
    add_filter( 'wp_nav_menu_items', 'bsp_register', 10, 2 );
    }
    
    function bsp_register ($menu, $args) {
    if( $args->theme_location == 'primary' ) {
    
    global $bsp_login ;
    if (is_user_logged_in())
    		return $menu;
    	else
    	$url = $bsp_login['Register PageRegister page'] ;
    	if (!empty($bsp_login['Register PageMenu Item Description'] )) {
            $desc=$bsp_login['Register PageMenu Item Description'] ;
    		}
    	else $desc=__('Register', 'bbp-style-pack') ;
    	$registerlink = '<li><a href="'.$url.'">'.$desc.'</a></li>';
    
    	$menu = $menu . $registerlink;
    	}
    		return $menu;
    
    }

    Let me know if this works

    Thread Starter Martijn

    (@ximie90)

    Perfect,

    Thanks a million.

    Plugin Author Robin W

    (@robin-w)

    great – glad you’re fixed !

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Login/logout button showing on all menu's’ is closed to new replies.