Ever since WordPress has introduced custom post types and has brought it from just a blogging platform to complete website framework solution, the need of having more user roles than the default ones have emerged. In other words, having same capabilities of a role under different custom names has arisen. This has also become relevant for Multi Author Blogs and Blog Networks. I remember many of the good blogs (ShoutMeLoud, Techiemania etc.) mentioning guest author information in posts submitted by their guest authors. That was something which inspired me to think of a way by which we can have a custom WordPress role like “Guest Author” for a multi author blog or some other type of fancy names having certain capabilities for other sites. After the extension of WordPress CMS capabilities, it is being used for creating websites and other type of web portals. I have recently created a learning portal using WordPress and their having the default WordPress Roles were not enough. Hence I created my custom roles with names which were very specific to that particular solution.
I have already created “Guest Author” Role for my blog ShoutingWords and all the guest contributors are assigned this role. You can also register yourself for the ShoutingWords Revenue Sharing Program and can share your ideas with the world. Lets see how we can create a custom WordPress role called “Guest Author”.
In this post, I will explain WordPress Roles and will also explain how to create custom user roles for your blog, assign capabilities to a role and do other things related to WordPress Roles. So, let’s get started!
WordPress has multiple user roles like subscriber, contributor, Author, Editor and Administrator with different capabilities. For a detailed list of Role Vs. Capabilities, you can visit this link on WordPress Codex. The lowest possible role with the capability to write a post is contributor, a contributor can write a post but he can not publish it. Usually every guest author on a multi author blog is granted the role of contributor so that an administrator or an editor can check the post and then publish it. What if you want to have the same capabilities as contributor but with a different name and/or you want to add some more capabilities to the contributor role and create a custom role which is specific to your blog or website. Here is how you can do that.
Create a WordPress Custom Role
The WordPress function to create a role is:
<?php add_role($role, $display_name, $capabilities); ?>
To create a role named “Guest Blogger”, you should update the following code in your WordPress Theme’s functions.php file.
/* Add guest author role to the blog */ add_role('guest_author', 'Guest Author', array( 'read' => true, // True allows that capability 'edit_posts' => true, 'delete_posts' => true, ));
The capabilities assigned above are similar to a contributor role but it is now with a different and custom name. If you wish, you can add more capabilities or you can also explicitly restrict this user for a specific capability. Just include any capability in the capabilities array of the above function and give its status true to enable it and false to restrict it.
Assign the Role to users
To assign the newly create custom role to your blog authors, you should login to your WordPress site admin dashboard. Now go to Users > Users.
Select the check boxes in the left hand side of all the users you want to assign this new role to. Now choose the new role and click on the change button.
I will post more information on how we can create and use custom WordPress roles to bring more life to our WordPress sites, until then do let us know your reactions and feedback about this article.