Tagged: woocommerce, WordPress Login:
Hello,
I would like to be able to give the customers the option to login to their accounts from the top menu. I have added the following code to my child functions.php file. However when I click on the login, it takes me to the default WordPress login instead of /my-account/ page.
Is there a way to redirect the user to my-account instead of the default WP login page?
//Adding Login to top menu
function add_login_logout_link($items, $args)
{
if(is_user_logged_in() && $args->theme_location == 'avia')
{
$newitems = $items;
$newitems .= '<li class=""><a class="" title="'.__('Logout','avia_framework').'" href="'. wp_logout_url( get_permalink( wc_get_page_id( 'myaccount' ) ) ) .'"><span class="">'.__('Logout','avia_framework').'</span></a></li>';
}
else if($args->theme_location == 'avia')
{
$newitems = $items;
$newitems .= '<li class=""><a class="" title="'.__('Login','avia_framework').'" href="'. wp_login_url( get_permalink( wc_get_page_id( 'myaccount' ) ) ) .'"><span class="">'.__('Login','avia_framework').'</span></a></li>';
}else{
$newitems .= $items;
}
return $newitems;
}
add_filter('wp_nav_menu_items', 'add_login_logout_link', 5, 2);
Hey Edna!
Please check the following, which will help you out:
http://wpscholar.com/blog/wordpress-user-login-redirect/
thanks a lot
Regards,
Basilis
Thank you very much Basilis. Issue can be closed
E.