How to use add_submenu_page() for editors?
-
18-03-2021 - |
题
Currently I load a custom WooCommerce sub menu point in an own plugin like:
// Add an additional submenupoint
add_action('admin_menu', 'register_mycustom_menupoint');
function register_mycustom_menupoint() {
add_submenu_page( 'woocommerce', 'Name on Menubutton', 'Name on Menubutton', 'manage_options', 'custom-submenu-page', 'dsrv_init_backend' );
}
function call_this_function_name(){
// ...
}
But this is only available for WP users at administration level. After searching the internet I tried to use edit.php?post_type=shop_order
instead of woocommerce
but then the menu point disappears. What do I have to change to fix it?
Woocommerce: 2.6.4, Wordpress: 4.6.11
解决方案
You should use edit_posts
capability instead of manage_options
. manage_options
is an administrator level capability. Try the following code -
add_submenu_page( 'woocommerce', 'Name on Menubutton', 'Name on Menubutton', 'edit_posts', 'custom-submenu-page', 'dsrv_init_backend' );