Wordpress 添加自定义角色以及删除默认角色 [英] Wordpress add custom roles as well as remove default roles

查看:86
本文介绍了Wordpress 添加自定义角色以及删除默认角色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要自定义默认角色,因为我只需要 3 个角色-管理员、买家、卖家.

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?

推荐答案

将此代码粘贴到您的主题 function.php 文件中,并根据需要进行自定义.这是来自我自己的代码库.所以它肯定会奏效.

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

这篇关于Wordpress 添加自定义角色以及删除默认角色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆