问题
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?
回答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');
来源:https://stackoverflow.com/questions/8413560/wordpress-add-custom-roles-as-well-as-remove-default-roles