Add a new role in wordpress

Add a new role in wordpress as following. Write down the following code into your functions.php file inside your theme

 add_role($role, $display_name, $capabilities); 


//add new role
 add_role('merchant_subscriber', 'Merchant Subscriber', array(
    'read' => true, // True allows that capability
    'edit_posts' => true,
    'edit_published_posts' =>true,
	'delete_posts' => false, // Use false to explicitly deny

The above example will create a new role as merchant subscriber. We can put condition with merchant subscribe in theme file as following:

 global $current_user;
if ($current_user->roles[0] == "merchant_subscriber")
   //do something
  //do another



2 Comment

  1. […] Vinay’s blog Gostou? compartilhe agora […]

  2. […] Vinay’s blog Posted by rick WordPress Permalink Tenha um atalho dos contatos dos usuários do WordPress […]

Leave a Reply