CASE STUDY:Extending WordPress Roles
I want to present a case study from a project I did with one of my clients where standard WordPress roles were not enough and we needed to extend the editor role. I’ll show you the process for extending WordPress roles in this post.
What Are Roles
Roles are the access control system of a WordPress site, they say what a person can do once they are logged into the dashboard, for example the admin role can do anything on your site, but the editor role can do anything regarding content, but cannot do admin style tasks such as installing plugins or themes.
WordPress has a number of predefined roles that users of your site can be assigned to, from most permissions down to least, the default roles are:
One Size Does Not Fit All
For the vast majority of people the six standard roles are more than enough, but there are certain scenarios where they are not quiet right, that is where we need to create a new role or extend an existing one.
The Editor That Needed More
In the case of my client, they were building a multi language site, they had a number of people on staff to create content for their site, and organised them into admin and editor roles.
The problem was that they wanted to send out content for translation to a third party translation company that was integrated into their site. Because there is a cost involved in this, the plugin in question WPML sets this function as an admin level task.
What we needed to do was extend the editor role and grant them a capability of wpml_manage_translation_management.
WordPress roles are assigned capabilities, there a hundreds of capabilities, some are default WordPress ones like activate_plugins whilst others are added by plugins and sometimes themes.
Here is a list of default capabilities to give you a feel for the granularity of control in WordPress.
User Role editor
The plugin I like to use to create custom roles is User Role Editor, This is a great little visual tool that allows us to create new roles or extend what we already have.
Once installed, under users -> user role editor you get this screen
To fix my clients problem, I simply opened up the editor role, and under the custom capabilities section I checked wpml_manage_translation_management. Simple as that.
Editors could see the translaton tool set and send out jobs for translation.
The roles ad capability system within WordPress allows for a lot of granularity on what someone can and more importantly cannot do once they are logged in. Consider using roles to stop the less technically able members of your team from breaking your WordPress site.
If you need help setting up custom roles for you WordPress site please feel free to request a quote from us.
Photo Credit: Nick in exsilio via Compfight cc