How do I email a new page password to somebody every month?

First of all, you should wrap your cron into a method: function cronjob_once_every_month() { // Our custom cron interval: $schedules[‘every_month’] = array( ‘interval’ => 1 * MONTH_IN_SECONDS, ‘display’ => ‘Once every Month’ ); } a) set up an automated email Then you should schedule an action: if ( ! wp_next_scheduled( ‘cronjob_once_every_month’ ) ) { wp_schedule_event( … Read more

run a cron task without obstructing page load?

Cron tasks don’t directly affect page load besides the 0.01s timeout (of course, they do affect server load, so they can impact page load indirectly). My hunch is that your PHP config is the issue. The cron tasks run like any other web request, and they’re subject to PHP’s max_execution_time INI setting. If this is … Read more

How to make sure a wp-cron job runs

Yes. No, because the scheduled job hasn’t reached the time yet. Yes, but not until 7:03pm. Basically, any hit to the site after the scheduled time will cause the queued job to run. The WP_Cron is a “best effort” system, not an exact timer. This is generally good enough though, since if nobody’s visiting the … Read more

wp_next_scheduled returning a past timestamp

Well, as I was working on an existing site which as maaaaany plugins already installed, I figured out that there was a define(DISABLE_WP_CRON,true); So when you seems to have the same problem than me. Do a research of define(DISABLE_WP_CRON,true); in your files.

How to run multiple Async HTTP requests in WordPress?

The (built-in) Requests class lets you call multiple requests simultaneously: Requests::request_multiple. <?php $requests = Requests::request_multiple([ [ ‘url’ => ‘https://www.mocky.io/v2/5acb821f2f00005300411631’, ‘type’ => ‘GET’, ‘headers’ => [ ‘Accept’ => ‘application/json’ ], ], [ ‘url’ => ‘https://www.mocky.io/v2/5acb821f2f00005300411631’, ‘type’ => ‘POST’, ‘headers’ => [ ‘Accept’ => ‘application/json’ ], ‘data’ => json_encode([ ‘text’ => ‘My POST Data’ ]) ], [ … Read more

wp_schedule_event() on specific time, daily

time() only returns current time, it doesn’t accept any inputs. $time = time(); // works out to 2016-04-11T12:11:34+00:00 What you want is midnight tomorrow: $tomorrow = strtotime( ‘tomorrow’ ); // works out to 2016-04-12T00:00:00+00:00 Note that these are PHP functions and they ignore WP timezone, since it resets PHP time zone to UTC. So if … Read more

Get frequency of scheduled event

This is an old question, but hopefully this helps someone facing the same issue. We can use wp_get_schedule( $hook ) to retrieve the cron schedule for the hook. Then we can use wp_get_schedules() to retrieve the supported cron recurrences. Find the correct array value and return it. /** * Retrieve Cron interval for hook. * … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)