• <?php
    
    /*
      Plugin Name: options menu
      Plugin URI:
      Description: chapter 3 multi-menu
      Author: adrian
      Version: 1.0
      Author URI: https://www.xymalf.com
    
    warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'ch3mlm_my_complex_submenu' not found or invalid function name in C:\wamp\www\WPDev\wp-includes\plugin.php on line 470
     */
    
    add_action ( 'admin_menu', 'ch3mlm_admin_menu' );
    
    function ch3mlm_admin_menu() {
    
    add_menu_page( 'My complex plugin configuration',
    'My Complex Plugin', 'manage options', 'ch3mlm-main-menu', 'ch3mlm_my_complex_main', plugins_url( 'myplugin.png', _FILE_ ));
    
    add_submenu_page( 'ch3mlm-main-menu',
    'My Complex Menu Sub-Config Page', 'Sub-Config Page',
    'manage_options', 'ch3mlm-sub-menu',
    'ch3mlm_my_complex_submenu' );
    
    }

    when I click on the sub menu page I am getting an error as in header even though file ch3mlm-sub-menu.php exists in the plugin directory.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The error message says it all:

    call_user_func_array() expects parameter 1 to be a valid callback, function 'ch3mlm_my_complex_submenu' not found or invalid function name

    Where is your function called ch3mlm_my_complex_submenu? It’s not in that code there, so unless it’s somewhere else you’re always going to get that error because the function doesn’t exist.

    Thread Starter xymalf

    (@xymalf)

    How should I write the function please. I am using a book for codes and obviously they omit some coding.

    I’ve told you this before…

    function ch3mlm_my_complex_submenu () {
        // Add your code in here.
    }
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘ch3mlm-sub-menu’ is closed to new replies.