Admin bar outside Front-end in WordPress.

Ẩn thanh Admin bar ngoài Front-end trong wordpress

When logging into WordPress with an account that has website management tasks, an Admin bar will appear at the top of the home page. This bar is not visible to members who register outside the front-end. To hide the Admin bar, code can be added to disable it for all users or only for non-admin members. Additionally, the greeting on the Admin bar can be customized using code. This customization can be applied to both the Front-end and Dashboard of WordPress. Overall, the Admin bar serves as a quick access tool for administrators, but it can be hidden or customized according to user preferences.

When you log into WordPress with any account, like author or editor, a black Admin bar appears at the top of the home page. This Admin bar is not visible to members who register an account outside the front-end or customers. They do not have access to the administration page, so the bar is hidden for them.

The Admin bar is designed to help administrators quickly access tasks inside the Dashboard. While it may sound convenient, some users find it annoying. If you are someone who dislikes the Admin bar, you can easily hide Admin bar by adding a simple line of code to the function file:

show_admin_bar(false);

If you only want to disable the Admin bar for non-admin members, while keeping it visible for Admins, you can use the following code snippet:

add_action('after_setup_theme', 'remove_admin_bar');

function remove_admin_bar() {

if (!current_user_can('administrator') && !is_admin()) {

  show_admin_bar(false);

}

}

By using this code, the Admin bar will only be visible to administrators and hidden from other members. As a result, you can customize the visibility of the Admin bar based on user roles.

See also  Important tasks to do immediately after installing WordPress

Additionally, you can tweak the greeting on the Admin bar for some fun. For example, changing "Howdy, admin" to "Hello, handsome:" can add a playful touch. Here’s the code snippet to achieve this customization:

function replace_howdy( $wp_admin_bar ) {

$my_account=$wp_admin_bar->get_node('my-account');

$newtitle = str_replace( 'Chào,', 'Hello handsome:', $my_account->title );

$wp_admin_bar->add_node( array(

'id' => 'my-account',

'title' => $newtitle,

) );

}

add_filter( 'admin_bar_menu', 'replace_howdy',25 );

With this code, you can replace the greeting on the Admin bar with a personalized message. Whether it’s on the Front-end or Dashboard, you can make the Admin bar experience more enjoyable for users with this simple tweak. Give it a try and see the result for yourself!

Overall, these tips provide practical solutions for customizing the Admin bar in WordPress to suit your preferences and enhance the user experience. Feel free to experiment with these codes and make the Admin bar work better for you.

5/5 - (1 vote)

Related posts