• Resolved brianstoiber

    (@brianstoiber)


    I am trying to have the admin or tool bar always visible even to logged out users. I have BuddyPress installed and checked the box that it provides for that but it is not working. I was wondering if there is another option for doing this outside of BuddyPress since it seems like there are may users of BP that have this same problem.

    The page I need help with: [log in to see the link]

Viewing 15 replies - 1 through 15 (of 15 total)
  • Hi there,

    if you add this to your child themes functions.php file it should show the admin bar to everyone at all times:

    add_filter('show_admin_bar', '__return_true', 1000);

    Best,
    Seb

    Thread Starter brianstoiber

    (@brianstoiber)

    It added the bar but the login link is missing.

    Ah my bad, missed that one sorry.

    please also add this code:

    function modify_admin_bar( $wp_admin_bar) {
    	if ( !is_user_logged_in() )
    	$wp_admin_bar->add_menu( array( 'title' => __( 'Log In' ), 'href' => wp_login_url() ) );
    }
    add_action( 'admin_bar_menu', 'modify_admin_bar' );
    Thread Starter brianstoiber

    (@brianstoiber)

    That then removes the bar:

    https://www.analyticsleaders.com/

    Oh yes sorry, it’s add_node instead of add_menu, like this:

    function modify_admin_bar( $wp_admin_bar) {
        $wp_admin_bar->add_node( array( 'title' => __( 'Log In' ), 'href' => wp_login_url() ) );
    }
    add_action( 'admin_bar_menu', 'modify_admin_bar' );

    don’t forget to keep the other line as well:

    
    add_filter('show_admin_bar', '__return_true', 1000);
    Thread Starter brianstoiber

    (@brianstoiber)

    So this is what I have in my functions.php file:

    add_filter('show_admin_bar', '__return_true', 1000);
    function modify_admin_bar( $wp_admin_bar) {
        $wp_admin_bar->add_node( array( 'title' => __( 'Log In' ), 'href' => wp_login_url() ) );
    }
    add_action( 'admin_bar_menu', 'modify_admin_bar' );

    You can also see it here: https://imgur.com/RxNKzmd
    The black bar appears but nothing in it.

    hmm the only thing I can think of is some plugin or other custom code modify the admin bar, I have tested this with twentynineteen theme and it works just fine.

    Can you try to disable your plugins and see if the code works without them?

    Thread Starter brianstoiber

    (@brianstoiber)

    I have disabled all plugins (renamin the plugin directory to plugin-disbale) and it does work. Any idea on how to track it down to a single plugin without disableing each individually?

    Thread Starter brianstoiber

    (@brianstoiber)

    I narrowed it down to the Membership 2 plugin. This site is a mess. They have Membership 2, BuddyPress, S2Members, and Members all running on it. Struggling to figure out what plugin they are actually using in their workflow.

    But thank you for your help.

    you’re welcome. glad you figured it out 🙂
    Yeah I’d suggest to use only one of these plugins otherwise conflicts are very likely.

    Thread Starter brianstoiber

    (@brianstoiber)

    What would I need to do to not show the Register link in the top left corner?

    to remove any links from the admin bar you can check this code example here:

    https://jasonyingling.me/removing-items-from-the-wordpress-admin-bar/

    Best,
    Seb

    Thread Starter brianstoiber

    (@brianstoiber)

    This doesn’t really give the option to remove the register link though.

    Thread Starter brianstoiber

    (@brianstoiber)

    Unfortunately, it doesn’t provide any method to remove Register.

    sorry have been off for the day.

    To remove the register link you need to add this line to the function:

    $wp_admin_bar->remove_menu(‘bp-register’);

Viewing 15 replies - 1 through 15 (of 15 total)

The topic ‘Always show Admin/Tool Bar’ is closed to new replies.