Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #305296

    regarding post: https://kriesi.at/support/topic/woocommerce-login-on-top/
    Using this adds login/logout to avia2 for WP itself. How do you modify this to log in/out of the WooCommerce account?

    #305302

    SOLVED:
    I added the following to functions.php.

    /*
     * Add WooCommerce Login/Logout to avia2 menu
     */
    add_filter( 'wp_nav_menu_items', 'add_loginout_link', 10, 2 );
    function add_loginout_link( $items, $args ) {
        if (is_user_logged_in() && $args->theme_location == 'avia2') {
            $items .= '<li><a href="'. get_permalink( wc_get_page_id( 'myaccount' ) ) .'">My Account</a></li>';
            $items .= '<li><a href="'. wp_logout_url( get_permalink( wc_get_page_id( 'myaccount' ) ) ) .'">Log Out</a></li>';
        }
        elseif (!is_user_logged_in() && $args->theme_location == 'avia2') {
            $items .= '<li><a href="' . get_permalink( wc_get_page_id( 'myaccount' ) ) . '">Log In/Register</a></li>';
        }
        return $items;
    }
    #305674

    Hey!

    Thank you for using our theme and the forum.

    Glad you found a solution to your problem.

    Fell free to come back with any further questions.
    Enjoy the theme.

    Regards,
    Günter

Viewing 3 posts - 1 through 3 (of 3 total)
  • The topic ‘WooCommerce account login/logout (not WP account)’ is closed to new replies.