With help of following code you can make a custom user role access the control panel. Following code works on hooks admin_init
or init
add_action( 'admin_init', 'my_custom_function' );
function my_custom_function() {
add_role( 'new_role', 'New Role' );
$role = get_role( 'new_role' );
$role->add_cap( 'edit_posts' );
$role->add_cap( 'edit_pages' );
$role->add_cap( 'edit_others_posts' );
$role->add_cap( 'create_posts' );
$role->add_cap( 'manage_categories' );
$role->add_cap( 'publish_posts' );
$role->add_cap( 'edit_themes' );
$role->add_cap( 'install_plugins', false );
$role->add_cap( 'update_plugin' );
$role->add_cap( 'update_core', false );
// add more capabilities as per you requirements
}
Related Posts:
- Adding fields to the “Add New User” screen in the dashboard
- Displaying the number of updates available in the Admin area
- What’s the difference between admin_url() and get_admin_url() functions?
- How to influence the information displayed on widget inside wp-admin
- How to override admin-bar style
- TinyMCE custom styles remove class when switching styles
- How do I create a new WP admin color scheme?
- Apply custom role capabilities to administrator (without plugin)
- AJAX handler throws 400 (Bad request) – why?
- wp-admin page is blank
- Roles & capabilities GUI that does not create separate table
- Replacing select2 in admin backend for all selects
- difference between add_object_page and add_menu_page
- How to fix a theme with page.php Default Template that accidentally deleted?
- Target a certain page within wordpress backend (admin) i.e. Pages > About
- How do I redirect upon login a specific user based on role?
- How can I rename the WordPress AJAX URL? [duplicate]
- How to add another user to this remove_menu function?
- Add a new subscriber role using a function
- How to add a column to the Trash page?
- Comments to only be seen by their author
- How to change menu icon which is overriden (i.e. by WooCommerce) [closed]
- How to test for Super Admin
- password protected post policy
- Custom registration URL lost when user makes signup mistake
- Custom function for specific user role
- Hide Author.php template from specific user role
- Removing the main link to Jetpack from the menu
- edit role display name and label name without plugins
- Access / Filter block variations in Gutenberg, in WordPress 5.6
- How to remove howdy dropdown menu content
- Add Featured image column into wordpress admin on pages AND posts
- Selective Product Category for Carousel
- create shortcode to list users with specific meta key value
- Toggle User Roles with button
- How to change or add user role after getting post request data about pay? [closed]
- Execute a ultimate member action when user role is updated
- How to force field validation first, then its values saved durning edit profile?
- Move ‘current-menu-item’ class on #adminmenu li from Posts to Pages for Taxonomy Edit Screen
- How to auto refresh when user change postcode
- Sections and tabs DRY – WordPress settings API
- How to install Segment on WordPress without a plugin
- Get First Child Page ID or Permalink in WordPress Admin
- Creating A New Admin Menu Tab For Theme Options
- Allowing users to view private posts (pending approval)
- wp-admin won’t load after setting wp-login custom url
- Wp admin – Set default value to 999 in comments
- Allow Contributor to edit their own posts after Adm aproval
- Remove “Published On” inside wp-admin
- Where do i create my own function in wp-admin
- How to remove comment count column in Posts inside the admin dashboard?
- What is the text that appears beside the page titles in the list of pages in the WP admin?
- How to add custom JavaScript in functions?
- How to set default post editor based on role?
- Sortable column (by numbers) in admin users
- load CSS only for administrators on backend
- Adding additional roles on registration
- error at login page in wordpress
- The Capability to choose post/page template
- How to add array [closed]
- Update to functions.php not showing in dashboard
- Add element to widgetpage
- Best way to disable sidebars on posts (only)?
- “options.php” not found
- Get users with different roles and call function on each of them (user_meta)
- How can I show different content for different user-levels?
- How to change a specific admin label
- Custom user role still showing up after deletion, ideas?
- How to change a meta value (of a published post) after X days.?
- Block all plug-ins from initiating redirection upon activation?
- How to add custom metakey to shop_order page’s searching function?
- How to load a css file depending on the current role
- Allow user select role in wordpress default registration without plugin
- Remove check boxes and its label from screen option for custom role
- Unable to login after registration
- Add Change role button for list of user in an event
- How to show only specific category post by user role without plugin and restrict all other cats
- Insert Modal on user first login
- Change user role based on total number of items ordered
- WP Enqueue Script Error
- Remove all video attachment, both files and post/postmeta from database?
- DISABLE wordpress upgrade page
- delete_user_meta for user in spesific group
- admin-ajax.php & my wp-admin folder url showing in header
- Change the second role depending on the first
- Restrict certain roles registrations by domain
- Multisite Admin Roles
- What is wrong with functions.php? Fills error log with same error
- How to add next height number in Order Attributes inside the Add new page. [duplicate]
- add_role menu pages are not visible
- Welcome Mails based on user role
- Changed functions.php file and now site is blank [closed]
- Get all users from role and add to dropdown (select) – wordpress, javascript
- Setcookie not setting cookies anywhere except admin
- Would it be possible to disable embeds for specific user roles? If so, how?
- How to make my logged-in user-role shortcode displaying name instead of slug?
- Custom User Role not working
- install Segment on WordPress
- Missing feature image link function
- How to check if a user is in a specific role?