Wordpress 使用添加角色挂钩仅显示自定义用户角色用户的自定义插件菜单
我在functions.php中为新用户创建了自定义用户角色,如下代码所示:Wordpress 使用添加角色挂钩仅显示自定义用户角色用户的自定义插件菜单,wordpress,plugins,user-roles,Wordpress,Plugins,User Roles,我在functions.php中为新用户创建了自定义用户角色,如下代码所示: add_action( 'admin_init', 'add_custom_roles' ); function add_custom_roles() { $student = add_role( 'student', 'Student', array( 'read' => false, 'assignments' => true, )); if
add_action( 'admin_init', 'add_custom_roles' );
function add_custom_roles() {
$student = add_role( 'student', 'Student', array(
'read' => false,
'assignments' => true,
));
if( null !== $student ) {
$role->add_cap( 'assignments', true);
}
}
只允许访问
学生
角色查看我的自定义插件页面:作业
,但它不起作用。自定义插件由add_menu_page
hook创建。您正在接近您的目标,为了帮助自己,您可以安装此()使功能处理更容易,然后调整设置以获得所需的男性可见性
您应该“克隆”进入后端所需的最低WP用户角色(如果我记得不错,应该是contributor),然后添加访问插件页面的自定义权限,但在这些插件中,我无法获得插件功能。我希望这些通过使用函数代码,而不是任何其他插件谢谢