Support » Fixing WordPress » do_action issue with parameters handling

  • Resolved Zatsugami

    (@zatsugami)


    Ok, so I wanted to hook up to an action post_updated.

    /* Line 2654 wp-includes/post.php /*
    do_action( 'post_updated', $post_ID, $post_after, $post_before);

    As you can see, there are 3 parameters. But when you look at do_action definition in wp-inludes/plugin.php you can notice.

    /* Line 386 */
    $args = array();
    	if ( is_array($arg) && 1 == count($arg) && isset($arg[0]) && is_object($arg[0]) ) // array(&$this)
    		$args[] =& $arg[0];
    	else
    		$args[] = $arg;
    	for ( $a = 2; $a < func_num_args(); $a++ )
    		$args[] = func_get_arg($a);

    Notice the for loop with $a set to 2. It means, that this will omit next 2 parameters.
    Is this made on purpose?

Viewing 1 replies (of 1 total)
  • Looks like there just need to be a 4rd parameter in add_action(name, function, order, number_of_accepted_params).

Viewing 1 replies (of 1 total)
  • The topic ‘do_action issue with parameters handling’ is closed to new replies.