Adding menu
-
I have tried adding this to my plugin to add a menu to the dashboard
`add_submenu_page(
‘xls-download’,
__( ‘XLS Download’, ‘xls-download’ ),
__( ‘XLS Download’, ‘xls-download’ ),
‘export’,
‘xls-download’
);`But I am getting
Fatal error: Uncaught Error: Call to undefined function wp_get_current_user() in …… public_html/wp-includes/capabilities.php on line 652
-
Working fine at my end, use below code
function custom_options_panel(){ add_menu_page('Custom page title', 'Custom menu label', 'manage_options', 'Custom-options', 'wps_Custom_func'); add_submenu_page( 'Custom-options', 'Settings page title', 'Settings menu label', 'manage_options', 'Custom-op-settings', 'wps_Custom_func_settings'); add_submenu_page( 'Custom-options', 'FAQ page title', 'FAQ menu label', 'manage_options', 'Custom-op-faq', 'wps_Custom_func_faq'); } add_action('admin_menu', 'custom_options_panel');You have issue with capabilities options.
add_submenu_page( 'xls-download', __( 'XLS Download', 'xls-download' ), __( 'XLS Download', ‘xls-download' ), 'export', 'xls-download' );should be like this
add_submenu_page( 'xls-download', __( 'XLS Download', 'xls-download' ), __( 'XLS Download', ‘xls-download' ), 'manage_options', 'xls-download' );I have change it to
function xls_download_menu() { add_submenu_page( 'xls-download', __( 'XLS Download', 'xls-download' ), __( 'XLS Download', 'xls-download' ), 'export', 'xls-download' ); }but the menu isn’t showing up? Is export correct? I would have thought so
I also put
add_action(‘admin_menu’,’xls_download_menu’); and it is calling the function alright
You should use
function xls_download_menu() { add_submenu_page( 'xls-download', __( 'XLS Download', 'xls-download' ), __( 'XLS Download', 'xls-download' ), 'manage_options', 'xls-download', 'render_view', 10 ); } function render_view() { // HTML Output }-
This reply was modified 6 years, 3 months ago by
Jogesh.
AH I have changed it to
function xls_download_menu(){
add_menu_page(‘XLS Download’, ‘XLS Download’, ‘manage_options’, ‘download’, ”);
}Thanks it shows up now
I am getting a 404 on the download page now. How do I create the actual download page with a form in it?
It is ok I have worked it out. A cup of coffee does wonders
Thanks
-
This reply was modified 6 years, 3 months ago by
The topic ‘Adding menu’ is closed to new replies.