我正在使用一个插件,它将一个子菜单项添加到管理菜单中,如下所示:
add_submenu_page( 'propertyhive', 'Property Hive Settings', 'Settings', 'manage_options', 'ph-settings', 'callback_fn' );
由于它说manage_options它只出现给管理员.我需要为编辑展示它.这是我在我的主题的functions.php文件中尝试过的:
add_action( 'admin_menu', 'custom_settings_menu', 99 );
function custom_settings_menu()
{
// Remove the submenu item first
remove_submenu_page( 'propertyhive', 'ph-settings' );
// Add it again but with different role (manage_propertyhive)
// This role does exist as other submenu items ue it
add_submenu_page( 'propertyhive', 'Property Hive Settings', 'Settings', 'manage_propertyhive', 'ph-settings', 'my_theme_callback_fn' );
}
Run Code Online (Sandbox Code Playgroud)
虽然这确实显示了子菜单项,但我收到以下错误:
Sorry, you are not allowed to access this page.
任何人都可以看到任何明显的或有任何倾向,可能会导致这种情况吗?
注:该manage_propertyhive能力绝对不存在