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
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' );
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);
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?
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?
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.
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
This doesn’t really give the option to remove the register link though.
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’);