Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /* Hide some plugins from the plugin list from everyone except user id 1 */
- /* Even other administrators can't see them */
- define( 'Z1_ADMIN_USER', 1 );
- $remove_these = array(
- 'limit-login-attempts/limit-login-attempts.php',
- 'wordpress-firewall-2/wordpress-firewall-2.php',
- 'update-notifier/update-notifier.php',
- 'wp-super-cache/wp-cache.php',
- 'audit-trail/audit-trail.php',
- 'wpmudev-updates/update-notifications.php',
- );
- add_filter('all_plugins', 'z1_remove_some_plugins');
- function z1_remove_some_plugins($all) {
- global $remove_these, $current_user;
- if ( isset( $current_user ) && ( Z1_ADMIN_USER != $current_user->id ) ) {
- foreach($all as $file => $data) {
- if (in_array($file, $remove_these))
- unset($all[$file]);
- }
- }
- return $all;
- } // end z1_remove_some_plugins
- /* Hide some menuss from everyone except user id 1 */
- /* Even other administrators can't see them */
- $remove_menus = array(
- array( 'options-general.php', 'limit-login-attempts' ), // submenu
- array( 'options-general.php', 'update-notifier' ),
- 'edit-comments.php', // top level core menu
- 'wpcf7', // top level plugin menu (contact form 7)
- array( 'options-general.php', 'wpsupercache' ),
- );
- add_action('admin_init', 'z1_remove_some_menus');
- function z1_remove_some_menus() {
- global $remove_menus, $current_user;
- if ( isset( $current_user ) && ( Z1_ADMIN_USER != $current_user->id ) ) {
- foreach ( $remove_menus as $m ) {
- if ( is_array( $m ) ) {
- remove_submenu_page( $m[0], $m[1] );
- } else {
- remove_menu_page( $m );
- }
- }
- }
- } // end z1_remove_some_menus
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement