I'm a bit lost on this one and would appreciate some direction. I have created a plugin that sends a message to a user after they successfully sign up. However, I would like this message to be sent 24 hours after the event is triggered (their account verification).


1 Answer 1


In below function take the registration date of the user and add 24 hours to the registration date. If current time matches the $notify time then send message.

$notify = date("Y-m-d H:i:s",strtotime("+24 hours",strtotime($registration_date)));
if(date("Y-m-d H:i:s")==$notify){
    //send message code
  • And where should this code go? How is it executed? Will it calculate the time diff for every user on every request?
    – kero
    Apr 1, 2021 at 7:30
  • You can use wp cronjob to run this code automatically in functions.php. This might help you somehow developer.wordpress.org/reference/functions/wp_schedule_event
    – Majid Ali
    Apr 1, 2021 at 7:32
  • Can you edit your information to contain this info? And if you use a scheduled event, is there even the need to calculate $notify anymore?
    – kero
    Apr 1, 2021 at 7:40
  • You just need to pass the user's registration date and inside the if condition write the code to send message. It will automatically calculate the notify time and if matched it will send the message (if there is no error in your message sending code
    – Majid Ali
    Apr 1, 2021 at 7:42
  • You need to calculate the notify time in order to send the message after 24 hours of registration. If there is a user who registered 1st April 9:00 AM then he would receive the message on 2nd April 9:00 AM and if there is a user who registered 1st April 9:00 PM then he would receive the message on 2nd April 9:00 PM
    – Majid Ali
    Apr 1, 2021 at 7:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.