Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I don't know what's wrong but the method that I'm trying to execute doesn't seem to be running when being called through wp cron. In the code below I'm trying to insert a new blog post. When I have the wp_mail function above the method that I'm trying to call it sends me an email, but if its below its not sending anything. I trigger the execution of this by refreshing the homepage.

wp_schedule_single_event(time(), 'one_time_event');


add_action('one_time_event', function(){

    set_time_limit( 300 );
    post_product();
    wp_mail('abc@gmail.com', 'one time event', 'has run');


});

But the thing is there's nothing wrong with the method that I'm calling as I've tried executing it by calling it via ajax:

function ajax_debug(){
  post_product();
}

add_action('wp_ajax_nopriv_debug', 'ajax_debug');
add_action('wp_ajax_debug', 'ajax_debug');

I also tried calling it from the admin_menu action:

add_action( 'admin_menu', function() {
  post_product();
});

Calling it both from ajax and admin menu works fine, I know because it doesn't show any errors and the post is published and it does everything that's in the method. But I don't know why its not working when being called through wp cron.

Any ideas how to determine what's really wrong with this method or what else can I try to make this work?

share|improve this question
    
Please provide debugging information, or check your server logs. –  s_ha_dum Apr 5 '13 at 2:14
    
I've set wp_debug to true and found a bunch of errors. I managed to fix all of them but the method is still not working. –  soul Apr 5 '13 at 3:16
add comment

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.