• Hi All,

    I have some strange problem and don’t understand why this doesn’t work:

    wp_schedule_single_event(time()+15, 'test_event');
    add_action('test_event', 'test_function');
    
    function test_function(){
    
    	echo 'IN test_function() FUNCTION';
    }
    
    //counter
    
    $cnt=wp_next_scheduled('test_event') - time();
    echo $cnt;

    This code should call test_function() after 15 sec.
    And print ‘IN test_function() FUNCTION’ on the screen.
    I’m refreshing screen and looking how counter goes from 15 to -10 but never see that it call function test_function()

    Can anybody help.

    Thanks!

Viewing 1 replies (of 1 total)
  • Thread Starter nikola123

    (@nikola123)

    Actually what doesn’t work is wp_schedule_single_event.

    This code from reference doesn’t work

    function do_this_in_an_hour() {
    // do something
    }
    add_action('my_new_event','do_this_in_an_hour');
    
    // put this line inside a function,
    // presumably in response to something the user does
    // otherwise it will schedule a new event on every page visit
    
    wp_schedule_single_event(time()+3600, 'my_new_event');
    
    // time()+3600 = one hour from now.
Viewing 1 replies (of 1 total)
  • The topic ‘add_action and wp_schedule_single_event Doesn’t Work – Please Help’ is closed to new replies.