You can just use the code I posted here. It is more customizable then the other one in the codex article and the other topic you linked to. I might change it in the codex article later on to this one too.
Login, Register, Lost Password links
You can put a custom page like this '/page-slug/'
. Here I made it so where when a user logs out they go to a page called “Logout” that has the permalink slug “logout”.
add_filter( 'wp_nav_menu_items', 'rkk_add_auth_links', 10 , 2 );
function rkk_add_auth_links( $items, $args ) {
if (is_user_logged_in() && $args->theme_location == 'sub-header-menu') {
$items .= '<li><a href="'. wp_logout_url('/logout/') .'">Log Out</a></li>';
}
elseif (!is_user_logged_in() && $args->theme_location == 'sub-header-menu') {
$items .= '<li><a href="'. site_url('wp-login.php') .'">Log In</a></li>';
$items .= '<li><a href="'. site_url('wp-login.php?action=register') .'">Register</a></li>';
$items .= '<li><a href="'. site_url('wp-login.php?action=lostpassword') .'">Lost Password</a></li>';
}
return $items;
}
Thanks @robkk – as always.