如果我理解你的意思,你所想做的应该是可行的。add_menu_page()
或相关子菜单和设置页面功能,接受所需功能的参数。例如:
add_menu_page( $page_title, $menu_title, $capability, $menu_slug, $function, $icon_url, $position );
第三个参数是“向用户显示此菜单所需的功能”将其设置为您自己发明的某种功能,然后
add that capability to your user:
$user = new WP_User( $user_id );
$user->add_cap( \'can_edit_posts\' );
Or to a role:
// get the the role object
$role_object = get_role( $role_name );
// add $cap capability to this role object
$role_object->add_cap( $capability_name );