In developing a plugin, a variable $staging_site is assigned a value, e.g., $staging_site = 'some_value' in the plugin's php file. Later in the same file a function is defined as

function stl_page($stagingSite) {
    $url = get_site_url();

    $allowed = strpos($url, $stagingSite) > 0;

Further context:

add_action('admin_menu', 'stl_action_page');

function stl_action_page($stagingSite) {
            'tools.php', 'STL Update', 'STL Update', 'manage_options', 'update_live', ['stl_page', 'stagingSite' => $stagingSite]);
    add_action('admin_footer', 'stl_script');

Yet the following appears when the plugin is accessed in admin:

Warning: call_user_func_array() expects parameter 1 to be a valid callback, second array member is not a valid method

1 Answer 1


You called:

add_submenu_page( 'tools.php', 'STL Update', 'STL Update', 'manage_options', 'update_live', ['stl_page', 'stagingSite' => $stagingSite]);

Note that the 6th parameter you passed was ['stl_page', 'stagingSite' => $stagingSite] which is not a callable type, and a callable is expected.

callable can be:

  • 'function_name'
  • [ $object, 'method_name' ]
  • [ 'class', 'static_method_name' ]
  • function() { /* I'm a lambda/closure/anonymous function yay */ }

In your case it expected the second thing in the array to be a string containing a function name, instead it got this:

'stagingSite' => $stagingSite

and had no idea what to do with it. It doesn't make a lot of sense, especially since the admin_menu action doesn't pass a parameter, so there will never be a $stagingSite.

So remove the $stagingSite argument in your function, and pass a proper callable value telling WP what to call to display that submenu page.

As a sidenote, I suspect you did this to pass a variable through to the function, you can't do that via callables, nor should you need to in this scenario

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.