WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a scheduled event that runs twice daily in my plugin, the action is registered with


function fhprw_check_fetch($args){

//do stuff according to $type

if I manually call a do_action('fhprw_action',array('type'=>'uk')); when a widget is updated then the function receives $args as an array and I can get $type from $args['type'] no problem

but when I schedule an event with

wp_schedule_event(time() , 'twicedaily', 'fhprw_action',array('type'=>$instance['type'])); // ($instance['type'] will be 'uk')

then the function receives $args as a string

$args = 'uk' instead of array('type'=>'uk');

why is the function not receiving an array for $args when it is called by the cron?


scheduled events call the callback function with a list of parameters, not an array of parameters so my callback function for the action would receive $arg1,$arg2 etc and wouldn't be able to accept an associative array

share|improve this question

It could be the phrasing of the array so try setting the array outside the wp_schedule_event call:

$args = array('type'=>$instance['type']);
wp_schedule_event(time() , 'twicedaily', 'fhprw_action',$args);
share|improve this answer
turns out that a scheduled event will call the callback function with call_user_func_array which means the function is called with fhprw_check_fetch($arg1,$arg2,$arg3) and not fhprw_check_fetch($arrarg); – CommentLuv Mar 19 '11 at 15:02
In which case, if you really wanted args passed back as an associative array, you could schedule with $args = array( array( 'type' => $instance['type'] ) ); – TheDeadMedic Mar 19 '11 at 15:08

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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