This code snippet hides the WordPress admin bar for users who do not have administrator privileges (specifically, those who cannot ‘manage_options’). It ensures a cleaner interface for non-admin users by removing the admin bar from the top of the website when they are logged in.
add_action('after_setup_theme', 'disable_admin_bar_for_non_admins'); function disable_admin_bar_for_non_admins() { if (!current_user_can('manage_options')) { add_filter('show_admin_bar', '__return_false'); } }