• Hello,
    There is something I don’t understand about cron, I would be glad if you could help me.
    On a plugin page, I am trying to send a message to the admin if certain events occur (e.g. after 4 days). The problem is: If the subscriber does not visit the page, the message is not sent. So it should load the page at least once.
    The question I want to ask is: How should I use Cron here? There are many codes and controls that I have added on the page. So there is no single function. As far as I understand, Cron only runs the function. Is there a way to run the page (related php file)? Or would it be sufficient to just run the function that sends the message?

    • This topic was modified 3 years, 6 months ago by Jan Dembowski. Reason: Expanded the title
Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator bcworkz

    (@bcworkz)

    You can just call the function, but what’s going to trigger the action? WP Cron will fire after any request, it doesn’t matter which page. Even search spiders will trigger it.

    Thread Starter loopforever

    (@loopforever)

    Thank you very much your response.
    Actually it’s a vendor plugin. Therefore, the seller must log in to the page. However, I am considering using admin_footer. Do you think such a code always works correctly ? Or do you have an alternative solution?

    Moderator bcworkz

    (@bcworkz)

    Maybe I’ve misunderstood how you apply WP_Cron. I now think you are scheduling the task from this login only page. Then of course there would be no cron task until the page is visited. But once scheduled, any request for anything will trigger the cron task after the appropriate time. No login required. But there does need to be some kind of request. If your site has very low traffic, cron tasks will not fire reliably.

    “admin_footer” will only fire for back end requests. If users are frequently in the back end, that may work for you. On low traffic sites, there are other ways to get a cron task to execute. There are various services that regularly check to verify that your site is still functioning correctly, that the server has not crashed. These checks will trigger cron tasks.

    Alternately, you could schedule a real server CRON job instead of using WP-Cron. Server CRON does not rely on traffic, it’s entirely clock based.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Cron trigger using a page the subscriber does not visit’ is closed to new replies.