Adding a callback to "update_option_{$my_option}" results in the error Too few arguments to function.

My callback accepts $old_value and $new_value. If I remove $new_value from the callback declaration and debug $old_value I am supplied with the correct $old_value. Why isn't $new_value being supplied by WordPress?

1 Answer 1


When you call add_action, you need to tell it how many parameters of the action that you want to receive. The default is just the first parameter. If you want more, then you tell it so.

add_action( 'update_option_whatever', 'example_callback', 10, 2 );

The 10 is the priority (10 is default).

The 2 is the number of parameters to send to your callback (1 is the default).

So if example_callback looks like this:

function example_callback( $old_value, $new_value )

Then you need that 10,2 on the add_action.


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.