我正在使用一个插件,它会像这样向管理菜单中添加一个子菜单项:
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' );
}
尽管这样做可以正确显示子菜单项,但我收到以下错误消息:
“抱歉,您无权访问此页面。”
有人看到了什么问题或者有任何想法是什么导致这个问题吗?
注意:manage_propertyhive权限确实存在。