Wordpress add custom roles as well as remove default roles

柔情痞子 提交于 2020-01-01 04:50:53

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!