0

After creating a parent admin menu item, which works fine, I fail to add a submenu page. Trying to var_dump the return value of add_submenu_page() I get 'null'.

My functions are:

    /**
     * Register the admin menu page
     * 
     * @since   1.0.0
     */
    public function add_admin_menu() {
        add_menu_page( 'WPQuotes', 'WPQuotes', 'manage_options', 'wp-quotes-plugin', 'wpq_admin_settings_page_main', 'dashicons-networking' );
        add_submenu_page( 'wp-quotes-plugin', 'New WPQ Form', 'New WPQ Form', 'manage-options', 'wpq-new-form', 'wpq_admin_settings_page_new_form');
    }

    public function run_all(){
        add_action( 'admin_menu', array($this, 'add_admin_menu'), 10 );
    }
1
  • There is no var_dump in your code, can you adjust it to demonstrate how you tested the return value of add_submenu_page? Is there a reason you don't use the return value of add_menu_page?
    – Tom J Nowell
    Mar 2, 2020 at 0:17

1 Answer 1

1

Your code is correct but just you have called wrong capability in add_submenu_page.

You just need to replace this 'manage_options' instead of 'manage-options'. And please check it. It's works.

Reference: https://developer.wordpress.org/reference/functions/add_submenu_page/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.