Created
August 30, 2017 23:18
-
-
Save pbrocks/9509496b8e50e820be61dd1520105b01 to your computer and use it in GitHub Desktop.
Hide the WordPress Toolbar for non-admins and non-Membership Managers
This file contains hidden or 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 | |
/** | |
* Plugin Name: PMPro Customizations | |
*/ | |
add_action( 'init', 'disable_toolbar_on_frontend', 9 ); | |
function disable_toolbar_on_frontend() { | |
if ( ! current_user_can( 'pmpro_membership_manager' ) | |
&& ! current_user_can( 'administrator' ) ) { | |
add_action( 'admin_enqueue_scripts', 'hide_toolbar_in_edit_user_settings' ); | |
add_filter( 'show_admin_bar', '__return_false' ); | |
} | |
} | |
function hide_toolbar_in_edit_user_settings() { | |
$current_screen = get_current_screen(); | |
if ( 'profile' === $current_screen->id || 'user-edit' === $current_screen->id ) { | |
?> | |
<style type="text/css"> | |
tr.show-admin-bar.user-admin-bar-front-wrap { | |
display: none; | |
} | |
</style> | |
<?php | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment