Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wordpress add custom roles as well as remove default roles

I need to customize the default roles as I need only 3 roles - administrator, buyer, seller.

Then I need to add the buyer, seller and remove all other default roles. What should I do?

If there is any ready made code which I can paste in and it will work?

like image 337
Roger Holga Avatar asked Dec 07 '11 10:12

Roger Holga


1 Answers

Paste this code in your themes function.php file and customize as your need. This is from my own code library. So it will definitely work.

/* Add member role to the site */
add_role('member', 'Member', array(
    'read' => true,
    'edit_posts' => true,
    'delete_posts' => true,
));

/* Add snypher role to the site */
add_role('snypher', 'Snypher', array(
    'read' => true,
    'edit_posts' => true,
    'delete_posts' => true,
));

/* remove the unnecessary roles */
remove_role('subscriber');
remove_role('editor');
remove_role('author');
remove_role('contributor');
like image 146
Samik Chattopadhyay Avatar answered Sep 23 '22 02:09

Samik Chattopadhyay