wp_schedule_single_event function not working
wp_schedule_single_event function not working
wp_schedule_single_event function not working
Not sure the exact answer but I have a theory that it is a 24 hour window. You can get around relying on wp-cron and someone visiting your site every day by having your server handle your cron. Assuming you have cpanel, it’s fairly easy to do. Then just have this run every 12 or … Read more
I tried WP Crontrol instead and it turned out that two cron jobs were being created for generate_send_csv. To fix this, I created the crons within activation hooks and deactivation hooks as follows: register_activation_hook( __FILE__, ‘my_activation’ ); add_action( ‘generate_send_csv’, ‘generate_and_send_csv’ ); function my_activation() { wp_schedule_event(‘1488979800’, ‘daily’, ‘generate_send_csv’); } register_deactivation_hook( __FILE__, ‘my_deactivation’ ); function my_deactivation() { … Read more
There is no reason for your design, but the core of your problem is that (I assume) people are trying to use a free tier of the API instead of properly paying for its use and removing the ridiculous restrictions. Anyway, the solution is fairly simple, run your cron every half an hour, allocate to … Read more
If you’re using the most recent version of WordPress, there are two ways you can update your plugins by just clicking a button (OK, maybe a couple, but it’s still really easy). Under Dashboard in your WP admin, there will an Updates option. Click on that and you should see something like this: Choose Select … Read more
While the idea that you are “developing some scrapping plugin” is sketchy and off-putting, the general question is “How do I fire code using system cron jobs?” and that is a valid question. You don’t need to jump through hoops to load WordPress. Set up an AJAX API callback… function fire_cron_job_wpse_144051() { // fire your … Read more
You do not need to use raw SQL, WordPress already provides WP_User_Query, and even provides examples of date based queries, for example the official docs say that this will retrieve all users registered within the last 12 hours: $args = array( ‘date_query’ => array( array( ‘after’ => ’12 hours ago’, ‘inclusive’ => true ) ) … Read more
OK, so first of all you’ll need to add your own WP_Schedule event: add_action( ‘wp’, function () { if (! wp_next_scheduled ( ‘mark_posts_as_featured_event’ )) { wp_schedule_event(time(), ‘daily’, ‘mark_posts_as_featured_event’); } } ); function mark_posts_as_featured_event_callback() { // if there are sticky posts in our CPT, unstick them $sticked_post_ids = get_option( ‘sticky_posts’ ); if ( ! empty ) … Read more
WP-Cron is not a guaranteed time task scheduler. The trigger for WP-Cron is somebody visiting the site itself, so if nobody visits the site at midnight, then the job doesn’t run until somebody does visit the site later. Similarly, if you use a whole page caching mechanism like WP-Super-Cache, then anonymous users will not really … Read more
I found a great solution here: Trigger a custom wordpress plugin with a linux cron My path was /usr/bin/wp so check your server. You can just add your function to a file, and using the wp bin script you don’t need to add anything to your php file to use WordPress functions. I was able … Read more