Notifications and WordPress Cron

What’s the issue?

Your SSA notifications may not go out exactly when you specify because of how WordPress works.

  • If you schedule an email notification to go out to your customer 1 day after they book an appointment, it may not actually be sent until 2 or 3 days later.
  • If you want to send a reminder email 1 hour before your customer’s appointment, it might not go out until 10 minutes before the appointment. Or possibly, it might not be delivered at all.

If you have a get thousands of visits to your site every day and are sending reminders with hours or days of notice, you probably won’t ever run into any issues. But if you have lower traffic or are trying to send time-sensitive notifications (like 10 minutes before an appointment), it will really help you to understand what’s going on here.

Why doesn’t it just work?

Your WordPress site is built to run and execute code when someone visits a page on your site. It doesn’t sit there using 100% processing power looking for jobs to do (this would be wasteful since WP primarily is built to display pages to visitors when they come to your site)

When a visitor goes to your home page, WordPress displays the page, and it also silently checks for any background tasks that it should be doing (and does them). This system is known as WP-Cron. It’s actually a pretty clever workaround for this issue.

The problem is: if your site gets only a little traffic, these background tasks aren’t run frequently. 

Here’s an example scenario:

  • You set up a reminder email in SSA to be sent to your customer 1 hour before an appointment
  • Your customer books an appointment for tomorrow at 9am
  • SSA immediately sends a confirmation email. (this works, yay!)
  • SSA schedules a reminder email to go out at 8am tomorrow morning

So at this point, we’re still ok. People visit your site through the evening. Each time, WordPress checks and says “nope it’s not 8am yet, I’m not going to send the reminder email right now”

  • At 2am, 3am, 4am… the site is quiet. Nobody’s visiting the site. WordPress isn’t checking to see if it should be sending emails.
  • If nobody visits your WordPress site until 8:30am tomorrow, that’s the first time WordPress checks and says “oh hey, it’s after 8am now and I have an email to send”
    • So your email might send at 8:30am instead of 8:00am when you expect. This isn’t the end of the world as long as you’re aware of it.
  • Worse, if nobody visits your site until 10am tomorrow, the “1hr reminder” notification wouldn’t go out until AFTER the appointment.
    • SSA is actually smart enough to not send a reminder email if the appointment is already in the past, but the customer wouldn’t get the reminder you wanted them to.

Surely there’s a fix for this, right?

Yes, it takes a couple minutes to set up, but then you can reliably depend on notifications going out when you expect them to.

  1. Set up a free account at Uptime Robot
  2. Create a monitor in Uptime Robot for yoursite.com/wp-cron.php

What have we done exactly?

Uptime Robot will visit your site every 5 minutes and trigger WP-Cron (the process where WordPress asks itself if there’s any work to do, like sending SSA notifications to your customers). Now, every notification will get sent to your customers on time (plus or minus 5 minutes of course). There are paid accounts on Uptime Robot that let you run checks every minute if you need even more accuracy.