1

I'm very new to this so any guidance is greatly appreciated. I've written a couple of simple plugins that will send an email to admins on new user save and and on new entry creation. What I need to do now is to send a weekly email with all new entries created in the last 7 days to a particular user group. I figured it'd be pretty efficient to set up an online CRON job to hit a site url, and on load of that page, trigger my email plugin. However, I'm not sure how to trigger my plugin on page load. Any suggestions?

4

I would think you would want to instead set up a controller action, as URLs route directly to them, rather than use the overhead of a page.

Your cron job could hit the corresponding Controller Action URL (i.e., http://mysite.com/actions/myplugin/entriescreated/weekly), and run your job like that. Note, where you're accessing an action via cron you would have to set it to allow anonymous access to the action.

http://buildwithcraft.com/docs/plugins/controllers

| improve this answer | |
  • Took me a minute to wade through that, but I got it. All working!!! Thanks! – Herb Himes Jul 31 '15 at 16:09
  • Question. I tested by just physically going to the action url. It returned a 404 page on the site. Is there a way to precent action urls from doing this? – Herb Himes Jul 31 '15 at 16:13
  • You'll need to trigger some sort of response to keep it from doing this: craftcms.stackexchange.com/questions/5401/… – Patrick Harrington Jul 31 '15 at 17:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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