Lance O. Posted September 30, 2019 Share Posted September 30, 2019 I want to create a hook that will: Check for pages with a specific template ("order"). Check that the page has a datetime field that is more than 30 days old. Send an email to a specific address. Change the value of a field to show the email was sent. What is the best hook method to use? I don't necessarily need this to execute on every page load on the public site, and it can't execute when viewing the specific template ("order"), but it can execute when the "orders" page is viewed on the public site. Link to comment Share on other sites More sharing options...
wbmnfktr Posted October 1, 2019 Share Posted October 1, 2019 Sounds like you could use LazyCron here. Check your pages how often you want (daily, weekly, each hour), look for those pages and do what ever you want to do with them. Put things like this in ready.php or create a module: <?php namespace ProcessWire; wire()->addHookAfter('LazyCron::every6Hours', function (HookEvent $e) { $pagesOlderThirtyDays = $e->pages->findMany("template=order, ... "); foreach ($pagesOlderThirtyDays as $potd) { // WHATEVER YOU WANT }; }); 7 Link to comment Share on other sites More sharing options...
Lance O. Posted October 2, 2019 Author Share Posted October 2, 2019 @wbmnfktr This is perfect, thank you! Thanks for steering me in a better direction. Link to comment Share on other sites More sharing options...
wbmnfktr Posted October 2, 2019 Share Posted October 2, 2019 You're welcome. ? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now