Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #1037279

    Hello Enfold Team!

    My site has a Header Meta bar at the top which displays some text on the left and the Secondary Menu on the right. The main menu is in the bar below that.

    I am trying to append a Login/Logout link to the Main Menu, right before the Search icon. I have been able to do that with the code attached, but now the Secondary Menu is gone. Am I taking the right approach, and is there something wrong with the code or a conflict with the Priority 9996?

    And where do we see a list of function Priorities?

    Thanks for everything!

    /* LOGIN MENU */
    //first append search item to main menu
    add_filter( 'wp_nav_menu_items', 'avia_append_login_menu', 9996, 2 );
    add_filter( 'avf_fallback_menu_items', 'avia_append_login_menu', 9996, 2 );
    
    function avia_append_login_menu ( $items, $args )
    {	
    	if(avia_get_option('header_position',  'header_top') != "header_top") return $items;
    
        if ((is_object($args) && $args->theme_location == 'avia') || (is_string($args) && $args = "fallback_menu"))
        {
            global $avia_config;
            ob_start();
                            
            if( is_user_logged_in() ) {
                $user = wp_get_current_user();
                $listclasses = "noMobile open-login menu-item menu-item-avia-special";
                $greeting = "Hi, ".esc_html($user->user_firstname)."!";
                $dashboardUrl = get_dashboard_url();
                $logoutUrl = wp_logout_url( home_url() );
                if( !current_user_can( 'administrator' ) && !is_admin() ) {
                    $submenu = '<a>My Profile</a>';
                } else {
                    $submenu = '<a href="'.$dashboardUrl.'">Dashboard</a>';
                }
                $logout = '<a href="'.$logoutUrl.'">Logout</a>';
                
                $loggedIn = <<<LOGGEDIN
                    <li class="$listclasses $class">
                        <a href="#">
                			<span class="btn-text">
                                $greeting
                            </span>
                            <span class="btn-icon">
                                <span class="dashicons dashicons-admin-users"></span>
                            </span>
                        </a>
                		<ul class="sub-menu">
                            <li>
                                $submenu
                            </li>
                            <li>
                                $logout
                            </li>
                        </ul>
                    </li>
    LOGGEDIN;
            } else {
                $listclasses = "noMobile open-login lrm-login menu-item menu-item-avia-special";   
                $loggedOut = <<<LOGGEDOUT
                <li class="$listclasses $class">
                    <a href="#">
            			<span class="btn-text">
                            Log In
                        </span>
                        <span class="btn-icon">
                            <span class="dashicons dashicons-admin-users"></span>
                        </span>
                    </a>
                </li>
    LOGGEDOUT;
            }
            if( is_user_logged_in() ) {
                $items .= $loggedIn;
            } else {
                $items .= $loggedOut;
            }
        return $items;
        }
    }
    #1038271

    Hey pkunzipula,

    Unfortunately, it would require quite some time and customization of the theme to achieve this, so I am sorry to tell you that this is not covered by our support. However, if it’s really important for you to get this done, you can always hire a freelancer to do the job for you :)

    Best regards,
    Basilis

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