Support » Plugins » Hacks » Add login/user and notifications from admin bar to main nav

Viewing 6 replies - 1 through 6 (of 6 total)
  • Moderator bcworkz


    The technique required would be theme dependent. How is the main nav menu generated? Static html? PHP template? Menu Widget? Does it support pull downs like those used in the admin menu?

    The link to the profile page is simple enough, but the logout link’s nonce must be added dynamically somehow, as it is different for every login.

    I am currently running a child theme of the BP Default theme. I coded the main nav into the header.php file.

    Here’s a sample:

    <div id="primary_nav" class="clearfix">
    		<ul class="ipsList_inline" id="community_app_menu">
    			<li id="nav_app_ccs" class="left">
    			<a href="">Home</a>
    			<li id="nav_menu_1" class="left">
    			<a href="">Store</a>

    Moderator bcworkz


    OK, static html then. As it turns out, the nonce bit is easy as well – there’s an app for that. err… rather a template tag for that. I neglected to mention though that you’d might want to conditionally display the menu items only to certain user roles, but the template tags are set up to display reasonable links to all users.

    It’s up to you, but I’d rather have a link to the dashboard instead of directly to my profile page. And there’s a tag for that too, so the conditional display becomes even less important, My example will only show the links to administrators, but you can use a different capability to cause display to more roles. You could even assign a custom capability if no capability common to all desired roles exists by default.

    My example only does a rudimentary side by side menu, if you need the pull down effect similar to the menu bar, it gets a bit more involved, there are many ways to implement it, working examples can be found on the internet. I’m not able to write code for it without doing some research myself.

    Insert above the closing </ul> tag for your menu.

    if ( current_user_can( 'manage_options')) { //remove this line and final curly brace to display to all users, change manage_options to display to more but not all users
      wp_register( '<li id="nav_menu_6" class="left">'); //displays link to dashboard if logged in, or to registration page if anyone can register, otherwise does not display. Direct link to profile is ''
      echo '<li id="nav_menu_7" class="left">';
      echo '</li>';
    } ?>

    Works great!

    Do you happen to know where I would find more template tags like the “wp_loginout()” tag?

    Moderator bcworkz


    There’s always Template Tags 🙂

    🙂 Thank you!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Add login/user and notifications from admin bar to main nav’ is closed to new replies.