-
Hi,
My theme has a top navigation bar before main menu with some information. I added manually in the header-navigation.php the register link and a custom login button.
I need that when users login, the register link and register button changes for the user name and logout link or a drop down menu with view profile, edit profile, messages, logout,etc…
The question is that i need to modify the .php and add the custom code for do it. can you help me? ^^
Thanks a lot,
regards.In my case I use the [usepro_loggedin] and [userpro_loggedout] but your navigation need to accept shortcodes!
Navigation login/logout links need shortcodes or custom coding. e.g. [userpro_loggedin] … to show content for logged in users. A conditional menu plugin can help you do this 🙂
But i need to do it adding custom code to my header-navigation.php
Can you help me to do that?Please, i need help desperately to custom the php code to do this. Can someone help me please?
Any idea of free conditional menu plugin? To trying more options…Thanks.
Class=\”popup-login botonlogin\”
“popup-login” calls the Userpro login popup. Also, if the user is login, show this popup:
I wrote mine like this
PHP12345678910111213141516171819202122232425262728293031323334353637/*Add Login / Logout to your WordPress Menu*/function userpro_add_loginout_navitem($items, $args ) {$theme_location = 'avia'; //Change "main_menu" to your own theme's main menu location$current_user = wp_get_current_user();if( $args->theme_location == $theme_location ) {if ( !(is_user_logged_in()) ) {$login_item = '<li class="nav-login menu-item"><a href="/profile/#" class="popup-login">Log In</a></li>'; //login display$login_item .= '<li class="nav-login menu-item"><a href="/profile/register">Register</a></li>'; //login display}else {//$login_item = '<li class="nav-login menu-item">'.wp_loginout($_SERVER['REQUEST_URI'], false).'</li>'; //logout display//$login_item = '<li class="nav-login menu-item">'.echo $current_user.'</li>'; //logout display$login_item = '<nav>';$login_item .= '<ul>';$items .= '<li><a href="#">'.$current_user->user_firstname.' '.$current_user->user_lastname.'</a>';$items .= '<ul>';$items .= '<li><a href="/profile/">My Profile</a></li>';$items .= '<li><a href="/my-projects/">My Projects</a></li>';$items .= '<li class="nav-login menu-item">'.wp_loginout($_SERVER['REQUEST_URI'], false).'</li>';$items .= '</ul>';$items .= '</li>';$items .= '</ul>';}$items .= $login_item;}return $items;}add_filter('wp_nav_menu_items', 'userpro_add_loginout_navitem', 10, 2);This actually shows the users first and last name when they log in and then when you hover over it it brings down a dropdown menu with my profile a project creation link which is specific to my clients needs, and the log out 🙂 works nicely.
It’s fantastic!
Can you upload the code by other way? I would like to try your work 🙂
Thanks for the contribution.Regards!
You must be logged in to reply to this topic.