• Resolved myladeybugg

    (@myladeybugg)


    I am looking to move or add part of the admin bar to my main nav bar. I would like to add the login/user and notifications to my main nav bar and hide the admin bar on the front end.

    I know how to remove it, but can’t seem to figure out how to add these features to my nav bar.

    This is the portion of the admin bar I need:
    https://i.imgur.com/PmZMA.png

    And here is where I would like to add it:

    View post on imgur.com

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

    (@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.

    Thread Starter myladeybugg

    (@myladeybugg)

    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="domain.com">Home</a>
    			</li>
    			<li id="nav_menu_1" class="left">
    			<a href="domain.com">Store</a>
    			</li>
    
                    </ul>
    </div>

    Moderator bcworkz

    (@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.

    <?php
    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 'domain.com/wp-admin/profile.php'
      echo '<li id="nav_menu_7" class="left">';
      wp_loginout();
      echo '</li>';
    } ?>

    Thread Starter myladeybugg

    (@myladeybugg)

    Works great!

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

    Moderator bcworkz

    (@bcworkz)

    There’s always Template Tags ??

    Thread Starter myladeybugg

    (@myladeybugg)

    ?? 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.