PHP Warning: call-user-func-array expects – WordPress

Warning: call_user_func_array expects parameter 1 to be a valid callback in WooCommerce and WordPress error solving Technique.

Share

Usually you get  PHP Warning: call-user-func-array expects error in WordPress or WooCommerce which means your theme break apart. The probability of this error when you want your WordPress do some action. The function you are calling is not available in your functions.php file. Error you get,

Warning: call-user-func-array expects parameter 1 to be a valid callback, function ‘___________’ not found or invalid function name in”.

For example, you add action for a function when WordPress load.

add_action('wp_loaded','my_function');

 

Now you did not declare my_function(){} then 100% you will face the error  Warning: call user func array expects parameter 1.

Error Solutions call_user_func_array :


Solution 1:

Try updating your WordPress or your Plugin so you can tackle the problem or ask plugin author forum to help you on this topic. Plugin update may help you because plugin author remove the function in the newest version.

Solutions 2 (Manually):

More often you delete the function and add_action call still available in your different part of the code. You need to comment out or remove the lines of add_action as well.  But if, for any reason, you forget to delete the add_action call, then you’re going to start seeing errors related to the call user func array in WordPress or WooCommerce.

This error hard to find to solve your problem as it doesn’t show which function is missing and where is the wrong add_action on the code. Try declaring the function it says missing like it says.

Warning: call-user-func-array expects parameter 1 to be a valid callback, function ‘some_function’ not found or invalid function name in”.

Try declaring the function it says missing;

if(function_exists('some_function')){
// function content
}
}

 

if this doesn’t solve the problem try

remove_action('some_function');

 

Solution 3 (WooCommerce):

If you removed an action by adding remove_action(‘__’,’__’). After that you add your own action make sure you write correct call. add_action . Because i commit a mistake while working mistakenly i add do_action instead of add_action.

That’s the WooCommerce point where you probably get the error “Warning: call-user-func-array expects parameter 1 to be a valid callback, function ‘___________’ not found or invalid function name in.

Leave a Reply

Your email address will not be published. Required fields are marked *