WP Smith

Creating WordPress & Genesis Websites Since 2010

  • Home
  • About
  • Services
  • Blog
  • Contact

Sep 12 2011

How to Add a Login Form to the Primary Navigation Menu in Genesis

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.

Primary Navigation with Login

[php]';
$login .= '';
$login .= '';
$login .= '';
$login .= '';
$login .= '';
$menu .= '

  • ' . $login . '
  • ';
    }
    // if logged in, do logout link
    else {
    global $current_user;
    get_currentuserinfo();
    $logout = '';
    $logout = 'Welcome ' . $current_user->display_name;
    $logout .= 'Logout';
    $menu .= '

  • ' . $logout . '
  • ';
    }

    return $menu;
    }
    [/php]

    Written by Travis Smith · Categorized: Tutorials, WordPress

    StudioPress Premium WordPress Themes     WP Engine Managed WordPress Hosting

    What can I do for you!?

    Custom Development

    We develop plugins by determining both business/functional and technical requirements, following WordPress development best practices, and using agile methodology to ensure you get the best solution.

    Consulting

    Have questions? Need a reliable developer to consult? Please contact us today!

    Customized Theme

    We can customize your theme or child theme, or create a child theme for you based on your needs while enhancing the performance of every individual attribute.

    Customized Plugin

    We can customize your plugins, extend plugins (e.g., Gravity Forms, Jetpack, Soliloquy) based on your needs ensuring security, performance, and positive business impact.

    Contact Us

    About Travis Smith

    As a WordPress enthusiast, developer, and speaker, Travis writes about what he learns in WordPress trying to help other WordPress travelers, beginners and enthusiasts with tutorials, explanations, & demonstrations.

    Comments

    1. Bruce Munson says

      September 13, 2011 at 7:55 am

      This is a great piece of information!
      Whoever asked this question must have real vision…

      Reply
    2. Adam W. Warner says

      September 13, 2011 at 9:51 am

      Thanks so much for sharing this. I have a large development project coming moving a Multisite install to Genesis and will need similar functionality.

      Reply
    3. Analytics says

      April 4, 2012 at 11:57 pm

      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.

      Reply
    4. Analytics says

      April 5, 2012 at 12:15 am

      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.

      Reply
      • Travis Smith says

        May 13, 2012 at 7:59 pm

        Hello,

        This is up to the style of your theme, and is not part of the code.

        Thanks,

        Reply
    5. Nathan says

      July 24, 2012 at 12:01 am

      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

      Reply
      • Travis Smith says

        July 24, 2012 at 4:15 pm

        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.

        Reply
    6. SISIGISIS says

      May 30, 2014 at 8:17 am

      does this code go into the theme’s functions.php file?

      Reply

    Leave a Reply Cancel reply

    Your email address will not be published. Required fields are marked *

    This site uses Akismet to reduce spam. Learn how your comment data is processed.

    • Twitter
    • Facebook
    • LinkedIn
    • Google+
    • RSS

    Copyright © 2026 � WP Smith on Genesis on Genesis Framework � WordPress � Log in