How to add new custom submenu under another plugin

2019-03-15 23:41发布

There is plugin called Shopp in my WP admin page , this plugin has got top level menu "Shopp" .

This is the top level menu:

$menus['main'] = add_menu_page('Shopp', 'Shopp', SHOPP_USERLEVEL, 'shopp-orders', array(&$this,'orders'));

And I've created some plugin which need to add as submenu under "Shopp" top level menu , so it is adding sub menu ( link .....wp-admin/admin.php?page=ach-faq.php ) but when I am clicking on submenu it shows "You do not have sufficient permissions to access this page."

Debug result:

Pagenow = admin.php
Parent = shopp-orders
Hookname = shopp_page_ach-faq
Menu = Array
Submenu = Array
Menu nopriv = Array
Submenu nopriv =
Plugin page = ach-faq.php
Registered pages =

My code:

function ach_faq_menu(){
 add_submenu_page('shopp-orders', 'My FAQ Plugin', 'My FAQ Plugin', 8, __FILE__, 'section_1');
}
function section_1(){
 echo 'Text';
}
add_action('admin_menu', 'ach_faq_menu');

How can I fix this ? Please help me !

7条回答
做个烂人
2楼-- · 2019-03-16 00:35
/*create any function name*/
function process_post() {

 add_menu_page(__('nLr','menu-test'), __('My Plugin','menu-test'), 'manage_options','myplugin', 'myplguin_admin_page', 'dashicons-tickets', 6 );

add_submenu_page('myplugin', __('My Plugin Edit', 'menu-test'), __('My Plugin Edit', 'menu-test'), 'manage_options', 'myplugin_edit', 'myplugin_edit');

 }
/*create callback function for main menu*/

function myplguin_admin_page(){
    echo"welcom to my plugin menu";

}

/* create callback function for submenu */

function myplugin_edit(){
    echo"welcome to submenu";
}
add_action( 'admin_init', 'process_post' );
?>
查看更多
登录 后发表回答