WordPress uses the concept of Roles to give the site owner control over what users can and cannot do on the site. By assigning each user a specific role, a site owner can manage user access to tasks such as writing and editing posts, creating pages, creating categories, moderating comments, managing plugins, managing themes, and managing other users. WordPress has six predefined roles: Super Admin, Administrator, Editor, Author, Contributor, and Subscriber, each with its own set of predefined permissions. But what if you want to give each role its additional custom set of permissions, like having new users to be able to edit pages? This article will show you how to add custom permissions to WordPress roles.
On the Theme Editor , select the Theme you want to edit from the dropdown:
The files for this selected theme are listed on the right column under Theme Files. Click on the file named “functions.php”:
Add this code snippet / function at the bottom of your functions.php file:
$result = add_role( 'new', __( 'New' ), array( 'read' => true, // so users can read 'edit_posts' => false, // so users can edit their own posts 'edit_pages' => true, // so users can edit pages 'edit_others_posts' => false, // so users can edit other author's posts 'create_posts' => false, // so users can create new posts ) );
With the above code snippet, you can turn the permission on / off by simple true / false value.
unfiltered_upload – This capability is not available to any role by default (including Super Admins). The capability needs to be enabled by defining the following constant:
define( 'ALLOW_UNFILTERED_UPLOADS', true );
Subscribe to receive weekly cutting edge tips, strategies, and news you need to grow your web business.
No charge. Unsubscribe anytime.