There’s actually a show_admin_bar
hook where you can always return true or false. I haven’t run across an issue where the admin bar is randomly disappearing though. Usually on my websites I like to turn it off for admins:
/**
* Remove Admin Bar For Administrators
* Or anyone who can activate plugins
*/
function theme_hide_admin_bar() {
return ( is_user_logged_in() && ! current_user_can( 'activate_plugins' ) ); // returns true or false
}
add_filter( 'show_admin_bar', 'theme_hide_admin_bar' );
OR you can permanently turn it off by just adding the following:
add_filter( 'show_admin_bar', '__return_false' );
Always show the admin bar:
add_filter( 'show_admin_bar', '__return_true' );