Do you know that others can access your website? By using WordPress user roles, WordPress site admin can safely and easily collaborate with people to assign different levels of access to their site and its content. This article will introduce readers to how WordPress user roles work and how to configure them on a WordPress website.
WordPress user roles
So, what is a WordPress user role, and what is the function? As the name suggests, it is a built-in user management function on a WordPress website. Actions that users can and cannot perform can be defined by a website owner, and group them into roles. Therefore, specific site management rights can be used to assign specific roles. WordPress provides six default user roles to provide more powerful website management capabilities.
Super administrator
The super administrator role only exists when the WordPress multi-site function is enabled. They are responsible for supervising all site administrators and multi-site networks. They can manage and change everything-from creating and deleting websites, to controlling content, themes, plugins, and configuration files.
After the super administrator role is enabled, the permissions of regular administrators will be reduced. They can no longer install themes and plugins, but they can choose to activate or deactivate them.
Administrator
Administrators can not only manage the operation of the site but also assign other roles. They can create, delete, review, edit and publish content, manage plugins and themes, and even edit code. This role also has the right to customize other user roles.
Editor
Editors have full access to all of the website content and their attributes. They can create, delete, review, and publish their own articles and articles created by other authors. Editors can also manage comments, post categories, and links. Users with this role usually supervise authors and contributors.
Author
Unlike editors who have complete control over the entire content section, authors can only fully control their own articles. They have the right to create, edit, delete and publish their own articles. In addition, they can edit their own user profiles.
Contributor
Similar to authors, contributors can create and edit their articles and profiles. The main difference between the two is that contributors cannot publish their articles.
Subscriber
This role can only read articles and manage their profiles. Basically, all visitors can read articles without being designated as subscribers. However, Visitors can be encouraged to become subscribers by providing special content that can only be viewed by them.
Things to do before setting up user roles
When deciding to set up user roles, it is best to follow some good practices.
Back up your website
Before making any changes, it is important to first back up the WordPress website. Not only can database form the hosting server be restored, but backup and uploading of files can also be done from local disk when needed. If switching to multiple user roles can cause any problems or security threats, it is easy to restore the site to its previous state.
Assign appropriate roles
Before assigning roles, consider user permissions. Choose what users can and cannot do.
Ask yourself, “Do you trust users?”, “Will they write, review, edit, publish, or maintain your WordPress site?”, “Can they fully or partially control your WordPress site?” Then begin to approve the role.
Best practices for configuring user roles
There are three ways to manage WordPress user roles.
Add users from the WordPress dashboard
Follow these steps to add, edit, and delete users in the dashboard:
- After logging in to the management area of the dashboard, select “Users” and select the “Add User” option.
- Fill out the form with the new user’s personal details, password configuration, and assigned roles. Make use of the “Add New User” key to save.
- After adding, editing, or deletion of users can be done by selecting all users from the drop-down menu.
To better control user roles, use one of the other two methods.
Manually modify the code in the template file
If more options are needed when configuring user roles, then adjusting the template files of the WordPress site is the answer. Modify the role by inserting code functions in the functions.php file. WordPress provides five code functions to customize user roles and their functions. They are:
- add_role ()-add a role
- remove_role ()-remove role
- add_cap ()-add functions to a role
- remove_cap () – remove a function from a role
- get_role ()-Get information about a role’s functions.
When writing actual commands, fill in:
- role – the designation of the character
- Display name – the name of the character on the WordPress dashboard
- Function-the permissions that the role will have. If you want to add multiple functions, you need to use an array.
For example, let’s add a role called Publisher, which can publish articles and pages:
add_role (‘publisher’, __ (‘Publisher’), array (‘publish_posts’ => true, ‘publish_pages’ => true,));
Visit the official WordPress codex to view the list of available features. To start using the code, follow these steps:
After building the code snippet, go to the management area and open the “Appearance” menu.
Click the theme editor in the drop-down menu, select the theme to edit, and then open the functions.php file.
Paste the code snippet at the bottom of the file.
Finally, click Update.
Pay attention to the code snippet because it can cause problems if it is not written correctly.
Use user role plugin
Although manually customizing WordPress user roles through code gives the most control, if it is someone not have coding skills, there may be risks. Alternatively, use plug-ins like Capability Manager Enhanced.
The plugin not only allows us to configure default WordPress user roles but also adds custom user permissions based on user needs.
After installing and activating the plugin, customize user roles from the WordPress dashboard. Click the “User” menu and select “Capabilities”. Then, an editor that allows for setting up roles and add features appear.