WordPress: for anonymous visitors disable admin toolbar

This is a machine-translated text. Original article

Under WordPress to disable the admin toolbar, it is sufficient to insert following code into the file "functions.php" of enabled themes:

function my_header_filter() {
    if (!is_user_logged_in()) { remove_action('wp_head', '_admin_bar_bump_cb'); }
}
add_action('get_header', 'my_header_filter');

function my_footer_filter() {
    if (!is_user_logged_in()) { remove_action('wp_footer', 'wp_admin_bar_render', 1000); }
}
add_action('get_footer', 'my_footer_filter');

Normally, a CSS code in the header, as well as a JavaScript code in the footer area including the toolbar is placed. The above code removes these code fragments before the header or footer will be issued.