0

I don't know what is missing here. I have a do_action() and add_action().

Only the first argument passed, to the function:

function testing($a, $b) {
    echo $a . $b; // Here is just get A, and an error for missing $b
}

$a = 'A';
$b = 'B';
do_action('test', $a, $b);

add_action('test', 'testing');

1 Answer 1

3

You have to say how many parameters your callback function needs. The default is 1, so WordPress will pass just $a. To get more parameters, use the fourth argument for add_action():

add_action('test', 'testing', 10, 2 );
1
  • Thx, I promised myself i read those documentations carefully.. :)
    – Iamzozo
    Oct 28, 2013 at 11:01

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.