Hide Admin Bar Pro is built with extendability in mind. If you’re a developer or agency looking to modify how the admin bar behaves programmatically, the plugin includes several filters and action hooks you can use to customize its behavior.
This guide documents the available hooks and how to use them.
Available Filters #
1. hab_pro_should_hide_admin_bar
#
Purpose:
Override or inject your own logic into the admin bar visibility decision.
Usage:
add_filter('hab_pro_should_hide_admin_bar', function( $should_hide ) {
if ( is_page('thank-you') ) {
return true;
}
return $should_hide;
});
Applies After:
All default visibility logic (roles, users, devices, etc.)
2. hab_should_hide_admin_bar_final
#
Purpose:
Filter the final decision for whether to hide the admin bar. Includes access to current user ID.
Usage:
add_filter('hab_should_hide_admin_bar_final', function( $final, $user_id ) {
if ( $user_id === 5 ) {
return true;
}
return $final;
}, 10, 2);
3. hab_export_settings
#
Purpose:
Modify the settings array before export.
Usage:
add_filter('hab_export_settings', function( $settings ) {
unset($settings['debug_mode']);
return $settings;
});
4. hab_pre_save_settings
#
Purpose:
Alter the settings array before it is saved to the database.
Usage:
add_filter('hab_pre_save_settings', function( $settings ) {
$settings['custom_note'] = 'Saved on ' . date('Y-m-d');
return $settings;
});
5. hab_pro_settings_fields
#
Purpose:
Dynamically modify or inject custom settings into the admin UI.
Usage:
add_filter('hab_pro_settings_fields', function( $fields ) {
$fields['custom_notice'] = [
'label' => 'Custom Message',
'type' => 'text',
'desc' => 'Show a note in plugin settings',
];
return $fields;
});
Developer Notes #
- All filters are namespaced and prefixed to avoid conflicts.
- You can combine these with WordPress’s native
show_admin_bar()
function to override logic globally. - Custom visibility logic should always return a boolean (
true
= hide,false
= show).
FAQ #
Can I hook into toolbar item rendering?
Not currently — but this will be exposed in a future version with hab_toolbar_items
.
Are these hooks available in the Free version?
Only hab_pro_should_hide_admin_bar
is exclusive to Pro. Basic role and capability filters are available in the Free version.