0

I am developing plugin in WordPress in which I want automatically and regularly call of PHP page if user visit the page or not.

Basically I am storing the date when user access the website and want to send mail using PHP file after one week. I am storing the current date and next week date in my plugin database. When one week passed and next date is arrived I want to send them mail.

As per this question, we can create JavaScript and make AJAX call to particular PHP page, compare current date and if next date in database and current date matches we can send mail.

But what if someone ain't access my site for next 10 days? Then there is no AJAX call for my PHP page, right? I mean that JavaScript and PHP page will not going to executed and mail will not send.

Plugin will be on any server and may be that server not allow for schedule task, so I think cron will also not going to work.

I want to call my PHP page if someone access my site or not. How can I do this process?

Your help will be appreciated. Thanks in advance.

Community
  • 1
  • 1
Kaushik
  • 79
  • 1
  • 8
  • What you are looking for is a "Cronjob". You can set it to which interval it should call a specific file. [link](https://stackoverflow.com/search?tab=votes&q=php%20cronjob) – ST2OD Jul 19 '16 at 06:18
  • 1
    Possible Duplicate of http://stackoverflow.com/questions/27210060/run-php-page-every-hour-automatically-without-using-cron-jobs?noredirect=1&lq=1 – Megan Fox Jul 19 '16 at 06:20
  • but while developing plugin for wordpress, do you think every this solution will work? I mean some server's not supported this function than what? And We cannot set this things for each and every site which will uses this plugin – Kaushik Jul 19 '16 at 06:21

1 Answers1

0

I think you need to break this problem down into smaller components.

If a user visits your site, make an AJAX call to update the date and time he accessed the site. That's the first step.

Next you'll need to have some type of scheduled job, if you're using Linux, you could use a cron job. This will run through and send the mails by checking the last time that the user logged in.

See more information here: Newbie: Intro to cron

Community
  • 1
  • 1
vsharper
  • 307
  • 1
  • 13
  • Yes, I do the exact same process. And I think scheduling job will also work. But for that loads of process need to done, like first disable wordpress inbuilt cron. then create my own one. and that run that cron using plugin. But I think in each and every site I have not access to change this wordpress inbuilt settings and setup my new. – Kaushik Jul 19 '16 at 06:33
  • we can not do it by any other way? – Kaushik Jul 19 '16 at 06:33
  • This is the best way, IMO, doing it any other way will not scale well. – vsharper Jul 19 '16 at 06:42