In functions.php of a theme makes a call to show_admin_bar(false) which hides admin bar in front end:

if (!is_admin())
    wp_deregister_style( 'bp-admin-bar' );
    if ( function_exists( 'show_admin_bar' ) )
        show_admin_bar( false );
        remove_action( 'bp_init', 'bp_core_load_buddybar_css' );

I want to make admin bar appear in front end for the admin users. To do this, I added the following code to a plugin:

add_action('plugins_loaded', 'show_admin_bar_to_admins', 100);
function show_admin_bar_to_admins()
    if (current_user_can('manage_options')) {

But this call didn't make a difference. I put 100 as the priority value such in order to make this function to be called later than the call inside functions.php. But it didn't make a difference.

Is there a way to make a function call inside a plugin to be executed later than the call inside functions.php.

2 Answers 2


First off: This Theme is so doing it wrong. One should not simply stuff plain calls in functions.php files. Those should be wrapped and hook. Best to after_setup_theme(). You could btw try the same hook.


I think the best way to show or hide the admin bar is by hooking into show_admin_bar filter, and specifying the conditions you need in the filter function:

add_filter('show_admin_bar', 'ad_show_admin_bar');

function ad_show_admin_bar($show) {
    // show front-end admin bar for admins only
    if(current_user_can('manage_options')) {
        return true;
    } else {
        return false;

This will take care of adding necessary scripts and styles for the admin bar as well.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.