Word press login logout menu with sub menus
-
Hi i have very little knowledge in programming, but try to make word press site by my self. i need to add “Login” to main nav-menu. with sub menu “register” (link https://www.vcanade.ca/register/)
after user logged in, “Login” has to change to his username with sub menus “profile” (link https://www.vcanade.ca/your-profile/) and “Logout”
is there way to do this?
does anyone can help me?so far i did only to display logged in user name by adding to fuction.php
[ Moderator note: code fixed. Please wrap code in the backtick character or use the code button. ]
add_filter( 'wp_nav_menu_items', 'your_custom_menu_item', 10, 2 ); function your_custom_menu_item ( $items, $args ) { $current_user = wp_get_current_user(); if(!empty($current_user->user_login)) $items .= ' <li><a href="void(0)">'.$current_user->user_login.'</a></li> '; return $items; }
- The topic ‘Word press login logout menu with sub menus’ is closed to new replies.