Search code examples
wordpresswoocommercehook-woocommerce

Warning: call_user_func_array() expects parameter 1 to be a valid callback


I'm getting this out of nowhere! Literally have done nothing,

Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'woocommerce_output_all_notices' not found or invalid function name in /wp-includes/class-wp-hook.php on line 287

            // Avoid the array_slice() if possible.
            if ( 0 == $the_['accepted_args'] ) {
                $value = call_user_func( $the_['function'] );
            } elseif ( $the_['accepted_args'] >= $num_args ) {
                $value = call_user_func_array( $the_['function'], $args );
            } else {
                $value = call_user_func_array( $the_['function'], array_slice( $args, 0, (int) $the_['accepted_args'] ) );
            }
        }
    } while ( false !== next( $this->iterations[ $nesting_level ] ) );

    unset( $this->iterations[ $nesting_level ] );
    unset( $this->current_priority[ $nesting_level ] );

    $this->nesting_level--;

    return $value;
}

Solution

  • The reason why you are getting that warning is already mentioned in comments section by @LoicTheAztec. I will quote his comment here:

    That is when a hooked function name doesn't match with the hook association… so for example when you have add_action('hook_name', 'function_name' ); and so function_name doesn't match with any declared function… This can happen when renaming a function, but not renaming the function name in the hook association.

    I will give some pointers on how to debug and resolve the issue. Since you mentioned that it happened all of a sudden and you have not done anything, I assume that it might be caused by a plugin. One of your plugin might be updated and the plugin developer might have made this mistake.

    What you can do is, visit your WordPress Admin Dashboard --> Plugins page. Then deactivate each plugin one by one. Make sure you check after deactivating each plugin, so that you would be able to figure out which plugin is causing the issue. While you are deactivating the plugins, if the warning disappeared, you would be able to tell that the plugin that you just deactivated is the villain here.

    Since you figured out the plugin causing the issue, check whether it has any updates available. If so, update that plugin and see if it resolves the issue. If no updates,

    1. you could try contacting the plugin developer, reporting the bug.
    2. or, you could try debugging and fixing the bug yourself (if you are comfortable with coding)

    If you plan to fix it yourself (#2), then try looking at the sourcecode of the plugin. Location would be : /wp-content/plugins/name_of_plugin

    You can use the File Manager in your cPanel or use FTP, to access the files. On each file of that plugin, you have to search for add_action(. And note down the second parameter, which would be callback function name. And search whether that function is defined somewhere. If not defined, then it could be mispelled. You have to find the mispelled function definition and change it's name to what is being used (as second parameter) of add_action()

    This will resolve the issue. In other case, while you are deactivating the plugins one by one and the warning message never disappeared even after trying to deactivate all the plugins, then you need look at your theme files (location: /wp-content/themes/your_current_theme_name_here/ )

    To search for the keywords within files, there's a good plugin called String Locator. I most often use it for debugging purposes. Might come in handy for you.