Replace all occurrences of $current_user->user_login == 'username'
with in_array('editor', $current_user->roles)
. And you can remove the call to get_currentuserinfo();
as for the user information is available from the global variable $current_user
.
Here’s a code swap:
add_action('_admin_menu', 'remove_editor_submenu', 1);
function remove_editor_submenu() {
global $current_user;
if(in_array('editor', $current_user->roles)) {
remove_action('admin_menu', '_add_themes_utility_last', 101);
}
}
add_action('admin_init', 'remove_theme_submenus');
function remove_theme_submenus() {
global $submenu, $current_user;
if(in_array('editor', $current_user->roles)) {
unset($submenu['themes.php'][5]);
unset($submenu['themes.php'][7]);
unset($submenu['themes.php'][15]);
}
}
Related Posts:
- Remove ability to access certain admin menus
- How can I restore admin capabilities?
- Change top level menu item to point to custom submenu item
- What determines whether admin toolbar is shown to a logged-in user?
- How do you set up a WordPress blog with multiple authors to allow something like StackExchange’s “community wiki” feature?
- current_user_can(‘administrator’) not working in custom login
- Redirect admin 403 “Cheatin uh?” admin pages
- Give admin_menu permission to specific users
- How can I create multiple different admin roles with their own capabilities
- Add a Separator to the Admin Menu?
- Adding a custom admin page
- How to remove entire admin menu?
- How do I remove dashboard access from specific user roles?
- Plugin to remove Admin menu items based on user role?
- Add separator to admin submenu
- Add my own button next to “Screen options” and “Help” in the admin
- Prevent author from changing their posts if admin has modified
- Make A WordPress Page Accessible To Admins Only, Redirect Other User Roles
- How to remove administrator role in settings -> general -> New User Default Role?
- Create un-removeable user
- Read only capability for custom post in admin area
- How to show custom menu items in the WordPress android app?
- Custom CSS In Admin Only For Certain Roles
- Remove admin AND editor from the “change role to” menu in user listing
- Appearance->Editor not visible
- Custom WP_List_Table displays blank rows
- How do I set up a webhook?
- Role that can edit only widgets, not other theme options
- How to remove “Super Admin” from All Users for those that are not a “Super Admin”?
- Customize the upload screen
- Admin pages have no content
- WordPress Left Hand Side Admin Menu Always Collapsed
- Blocking Administrative Access to Authors and Subcribers?
- Customize Admin Users Screen based on Role
- Make certain pages uneditable by editors?
- Reorder plugin items in the admin menu
- Re-ordering Admin Submenu Sections
- How do I code access to the built-in UI of a CPT when it’s placed as submenu of another CPT that is protected by role?
- Reference external file as a function
- Add number new posts (post_status = pending) to administration menu [duplicate]
- how to only add a top-level admin menu without it creating a sub-level-menu
- How to allow “Add New” capability of CPT when links to its UI are placed as a submenu?
- How to change menu page capability
- add_submenu_page set for multiple roles [duplicate]
- Restrict dashboard access for specific user roles to specific actions
- How To Create User Specific Admin User Pages?
- Change the Default Pages Menu View in wp-admin
- How to change admin menu position of “Media”?
- Associating custom submenu item with post type of top level menu item
- Admin doesn’t have sufficient permissions to plugin’s page
- Remove Admin sidebar link
- Single category’s posts list in admin menu
- Admin – Load existing admin template as a submenu page
- Custom post types as sub menu pages and role capabilities issue
- Dashboard menu missing
- Admin cannot publish
- Role capability issue
- page not updating with database
- Why am I timing out when using the Menu Editor?
- 500 internal server error on wp-admin only
- Only Admin can Edit, Delete or Update
- add_cap for editor but no admin role
- How can I POST or GET to the same admin page from which I am POST-ing or GET-ing
- Shared account / dual blogging in WordPress
- Output the admin menu_position for each item
- Bind custom role to admin page
- Access for adding subpages but not for pages
- avoiding the display of certain categories to certain user roles at content entry time
- remove menus for a specific role?
- How can I add a menu item to the admin area?
- Backend Checkboxes working – but not visual?
- WordPress Admin Menu Order for ‘admin.php’ pages
- Show global Message in User Profiles with admin only Input field in WordPress Backend
- How to make sure your admin doesn’t hi-jack you site?
- Remove specific administrator’s capability
- Given multiple admin accounts, how can I make it so that only admin with X username can edit posts
- How should I setup the “Users” area to hand over to a client?
- solution to prevent specific admins from altering site contents
- Admin user roles/permissions
- “sufficient permissions” error for admin after duplicating WP database to new install
- Posts in sidebar only by admin
- How to hide plugin options for editors via functions.php
- User role and capablities only for 1 plugin
- Show all admin menus in a table
- hide page menu from admin panel for specific users
- Highlight active Admin Menu when added though add_menu_page
- require/include php file in add_menu()
- Cannot access wp-admin after installing SSL – user capabilities not being set
- Create WordPress Menu Item Without Linking to a Custom Page
- Redirect non-admin after login, and in url – /admin
- Hide top admin panel for non admin and non editors
- Different role for free and pro users in wordpress without using bbpress
- Simple CSS admin pagination
- add_role menu pages are not visible
- How to change the default url for ‘Posts’ link?
- Unsure how to add simple checkboxes that write to a small table to admin
- Add a link to the Admin menu
- Capability to read/edit page in wp-admin only for administrators
- Reference external file as a function
- Grant access to admin menu?