[wp-hackers] Problem with wp_schedule_single_event
Otto
otto at ottodestruct.com
Thu Mar 20 19:52:13 GMT 2008
$data needs to be an array containing the parameters. Like this:
wp_schedule_single_event(time()+3600, 'my_custom_hook', array($data) );
add_action('my_custom_hook','my_function')
function my_function($data) {
//whatever
}
If you were to have multiple params, you'd do something like this:
wp_schedule_single_event(time()+3600, 'my_custom_hook', array($data1,
$data2) );
add_action('my_custom_hook','my_function')
function my_function($data1, $data2) {
//whatever
}
On Thu, Mar 20, 2008 at 1:13 PM, Sudar Muthu <sudar at sudarmuthu.com> wrote:
> Hi all,
>
> I am facing a strange problem with wp_schedule_single_event function when
> passing parameters to the callback function.
>
> The following is my condensed code
>
> wp_schedule_single_event(time()+3600, 'my_custom_hook', $data );
> add_action('my_custom_hook','my_function')
> function my_function($data) {
> //print $data
> }
>
> My aim is to pass the parameter $data to my_function(), but the above code
> is not working for me. The $data variable inside the my_function is always
> set to null.
>
> The documentation for the wp_schedule_single_event at
> http://codex.wordpress.org/Function_Reference/wp_schedule_single_event says
> that we can pass the arguments for the callback function as the third
> parameter but it doesn't seem to work for me. Am I missing something here?
>
>
> --
> With Regards,
> Sudar
>
> http://SudarMuthu.com
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>
More information about the wp-hackers
mailing list