Created
March 19, 2016 13:21
-
-
Save michaeloeser/a0691a3d06b6d27ab02d to your computer and use it in GitHub Desktop.
Customize the WordPress Toolbar for non-admin Users
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Redirect to homepage after logout | |
add_action('wp_logout','go_home'); | |
function go_home(){ | |
wp_redirect( home_url() ); | |
exit(); | |
} | |
// Customize the toolbar for non admins | |
function change_toolbar($wp_toolbar) { | |
if ( !current_user_can( 'manage_options' ) ) { | |
$wp_toolbar->remove_node('wp-logo'); | |
$wp_toolbar->remove_node('site-name'); | |
$wp_toolbar->remove_node('search'); | |
$wp_toolbar->remove_node('my-account'); | |
$wp_toolbar->add_node(array( | |
'id' => 'loguserout', | |
'title' => '→ Logout', | |
'href' => wp_logout_url( get_permalink() ) | |
)); | |
} | |
} | |
add_action('admin_bar_menu', 'change_toolbar', 999); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Some ideas taken from http://www.sitepoint.com/change-wordpress-33-toolbar/