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?

Read More

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

Related posts

Leave a Reply

1 comment

  1. 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');