Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/313.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wordpress 使用添加角色挂钩仅显示自定义用户角色用户的自定义插件菜单_Wordpress_Plugins_User Roles - Fatal编程技术网

Wordpress 使用添加角色挂钩仅显示自定义用户角色用户的自定义插件菜单

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

我在functions.php中为新用户创建了自定义用户角色,如下代码所示:

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),然后添加访问插件页面的自定义权限

,但在这些插件中,我无法获得插件功能。我希望这些通过使用函数代码,而不是任何其他插件谢谢