0

This started happening after I moved my wordpress installation from the shared hosting to a vps.

The full error is this:

Warning: call_user_func_array() expects parameter 1 to be a valid callback, array must have exactly two members in /home/pcsteps/public_html/wp-includes/plugin.php on line 199

I get it only when I install or update a plugin. It doesn't seem to affect the plugin's function in any way.

The line mentioned on plugin.php is the following:

195     do {
196     foreach( (array) current($wp_filter[$tag]) as $the_ )
197         if ( !is_null($the_['function']) ){
198             $args[1] = $value;
199             $value = call_user_func_array($the_['function'], array_slice($args, 1, (int) $the_['accepted_args']));
200         }
201
202 } while ( next($wp_filter[$tag]) !== false );

I 've looked far and wide on the internet, but couldn't find a solution.

Any help is welcome :)

  • This is a pretty generic warning and could be coming from just about any plugin. (Are you sure that's the only error message you're getting?) Deactivate all your plugins and then activate them one-by-one until you find the offending plugin. Then contact that plugin's developer with the bug report. – mrwweb Aug 28 '14 at 19:49
8

This is a tricky one. You don't really need to look at wp-includes/plugin.php, there is nothing wrong with that file, it's a core file so you should just leave it alone, like all the other core files.

The reason it's tricky is because actions and filters in core expect a working callback function, but when you add_action or add_filter it never really validates the callback. In fact, it never validates it when doing do_action and apply_filters either, but instead it's passing it straight to call_user_func_array.

So whenever you see this error (or it's non-array sister errors), it simply means that some theme or plugin is doing something wrong with add_action or add_filter:

add_action( 'init', 'function_that_does_not_exist' );
add_action( 'init', array( 'Class_Name', 'method_that_does_not_exist' ) );
add_action( 'init', array( 'Non_Existent_Class', 'method' ) );
add_action( 'init', array( 'Class_Name', 'method', 'huh?' ) );
add_action( 'init', array( 'Just a bogus array' ) );

Your specific error is the case #4, which is passing a callback as an array, but has more than 2 values in the array, and that's what PHP is complaining about. It's a pretty common mistake with WordPress actions, priorities and arguments:

add_action( 'foo', array( $this, 'bar', 10, 2 ) );

See, it sort of looks like we attached to foo with our bar method at priority 10 with two arguments. But in reality we're passing an array of four elements as the callback function. This is what we really intended to do:

add_action( 'foo', array( $this, 'bar' ), 10, 2 );

Note how the callback is a 2-element array, and 20 and 2 are the third and fourth arguments to add_action.

Hope that sheds some light onto what's happening with your plugins.

|improve this answer|||||
  • thanks a lot that was the error for me as well!!! add_action( 'user_profile_update_errors', array( $this,'crf_user_profile_update_errors'), 10, 3 ); it's correct while I was using add_action( 'user_profile_update_errors', array( $this,'crf_user_profile_update_errors',10,3) ); – loretoparisi Jul 22 '18 at 14:41
0

I'm not sure of exactly what $the_['function'] is, but you are getting an error for that.

expects parameter 1 to be a valid callback, array must have exactly two members

This is stating that $the_['function'] is not a valid callback for the reasoning of it not being two members. The error itself states the problem.

This might not be enough code to get a solution. Can you display a bit more code?

PS: it won't let me add a comment on the question due to me spending my reputation points

|improve this answer|||||
-2

Check your php version.. It should be on php 7.0 or less but non php 7.1 because the php version 7.1 is unstable so causing lots of bug.

Thanks

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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