Someone contacted me to develop a function that would add a login form to the primary navigation for their Genesis menu, and I would like to share it with you.
[php]';
$login .= '';
$login .= '';
$login .= '';
$login .= '';
$login .= '';
$menu .= '
';
}
// if logged in, do logout link
else {
global $current_user;
get_currentuserinfo();
$logout = '';
$logout = 'Welcome ' . $current_user->display_name;
$logout .= 'Logout';
$menu .= '
';
}
return $menu;
}
[/php]
Bruce Munson says
This is a great piece of information!
Whoever asked this question must have real vision…
Adam W. Warner says
Thanks so much for sharing this. I have a large development project coming moving a Multisite install to Genesis and will need similar functionality.
Analytics says
How to use this code?
I mean it would be great if you can have similar pluggin for this function or atleast mention where to place this code so it works for novices like me.
Anyway thanks for this.
Analytics says
Another question…
Copied at the end of menu-primary.php . It is working fine but it is not aligning to right and hence not looking good. Need it in the right side. Also a register button should have helped a lot, may be in place of remember me.
Travis Smith says
Hello,
This is up to the style of your theme, and is not part of the code.
Thanks,
Nathan says
Hi Travis,
Awesome tutorial, what I am trying to figure out is how to have a login form (username, password, send button) as a drop down in my secondary menu.
If you look at http://www.thaytea.com/site, you will see the secondary menu at the top of the page, I want the farthest right drop down to have that login form. Is this doable with the code above?
Thanks a bunch,
Nathan
Travis Smith says
Nathan,
Not sure, but probably not. This code snippet adds the item to the end of the nav menu items list. What you are seeking to do may require something of a custom Walker class, or some other customize menu output. You may want to try Uber Menu; it really is worth the $16.
SISIGISIS says
does this code go into the theme’s functions.php file?