Tagged: 

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #22788

    Hi there, you said, Enfold ist Woocomerce compatible. How can I integrate a Login / Logout link into the top header?

    #117233

    Insert following code at the bottom of functions.php:

    function add_login_logout_link($items, $args)
    {
    if(is_user_logged_in() && $args->theme_location == 'avia2')
    {
    $newitems = '<li><a title="'.__('Logout','avia_framework').'" href="'. wp_logout_url(get_permalink()) .'">'.__('Logout','avia_framework').'</a></li>';
    $newitems .= $items;
    }
    else if($args->theme_location == 'avia2')
    {
    $newitems = '<li><a title="'.__('Login','avia_framework').'" href="'. wp_login_url(get_permalink()) .'">'.__('Login','avia_framework').'</a></li>';
    $newitems .= $items;
    }else{
    $newitems .= $items;
    }
    return $newitems;
    }
    add_filter('wp_nav_menu_items', 'add_login_logout_link', 10, 2);

    You maybe need to replace “avia2” with “avia” or “avia3” (depends on the menu you want to use for the login/logout links).

    #117234

    Great, thx. The Login / Logout is now 1st point in the navigation. Is there a way to put it at the end, just before the search button?

    #117235

    Yes, use following code:

    function add_login_logout_link($items, $args)
    {
    if(is_user_logged_in() && $args->theme_location == 'avia2')
    {
    $newitems = $items;
    $newitems .= '<li><a title="'.__('Logout','avia_framework').'" href="'. wp_logout_url(get_permalink()) .'">'.__('Logout','avia_framework').'</a></li>';
    }
    else if($args->theme_location == 'avia2')
    {
    $newitems = $items;
    $newitems .= '<li><a title="'.__('Login','avia_framework').'" href="'. wp_login_url(get_permalink()) .'">'.__('Login','avia_framework').'</a></li>';

    }else{
    $newitems .= $items;
    }
    return $newitems;
    }
    add_filter('wp_nav_menu_items', 'add_login_logout_link', 5, 2);

    #117236

    Super, perfekt. Danke!

Viewing 5 posts - 1 through 5 (of 5 total)
  • The topic ‘WooCommerce Login on Top’ is closed to new replies.