wp_schedule_event is not working

1

I have the following function created in my functions.php . I am changing the theme to schedule, and I can see that it is scheduled by the next_schedule function.

add_action( 'after_switch_theme', 'prefix_setup_schedule' ); 

function prefix_setup_schedule() {
    if ( ! wp_next_scheduled( 'sendemail' ) ) {
        $timeschedule = strtotime(date("Y-m-d 18:00:00"));
        wp_schedule_event( $timeschedule, 'daily', 'sendemail');
    }
}

function sendemail()
{
    update_option('envioemail','feito');
}

However, this code is not running, does anyone have any ideas?

    
asked by anonymous 16.04.2014 / 21:17

1 answer

1

I was able to solve as follows, first the wp_schedule_event looked like this:

wp_schedule_event( $timeschedule, 'daily', 'my_daily_event');

Then I created an action like this:

add_action( 'my_daily_event',  'sendemail' ); 

and the function was normal, so my problem was solved.

Response based on question author's comment .     

13.04.2017 / 14:59