Niklas Posted January 21, 2016 Share Posted January 21, 2016 Hey everyone, i want to send an E-Mail every time somebody create an page with alle the fields from the page. Anyone know how i can do it? Greets, Niklas Link to comment Share on other sites More sharing options...
LostKobrakai Posted January 21, 2016 Share Posted January 21, 2016 $wire->addHookAfter("Pages::added", function(HookEvent $event){ $page = $event->arguments(0); // Do what you need to do with the page's data }); Put this in e.g. /site/init.php or add it to a module. 1 Link to comment Share on other sites More sharing options...
Niklas Posted January 21, 2016 Author Share Posted January 21, 2016 Thank you, and how can i send an E-Mail with it? Link to comment Share on other sites More sharing options...
LostKobrakai Posted January 21, 2016 Share Posted January 21, 2016 Look for wireMail or one of it's extention modules here in the forum. Link to comment Share on other sites More sharing options...
kongondo Posted January 21, 2016 Share Posted January 21, 2016 There's an example here as well: https://processwire.com/talk/topic/6562-sending-email-after-moving-page-from-one-parent-to-another/?p=64588 Link to comment Share on other sites More sharing options...
Niklas Posted January 30, 2016 Author Share Posted January 30, 2016 Thank you very much for your help. Now i am become a mail when new page is created.But the problem is, that i want the Page URL of the new page in die mail, but that wont be delivered. What is wrong with my code? <?php $wire->addHookAfter("Pages::added", function(HookEvent $event){ $page = $event->arguments(0); // Email address of user that created page $userEmail = 'hello@test.com'; // preparing and sending email $subject = __("Neue Lieferanfrage von Website"); $textBody = sprintf( __("Guten Tag, Sie haben eine neue Lieferanfrage. Klicken Sie auf den Link um sie zu sehen:"), $page->url); $from = 'hello@test.com'; // if you have defined it in config page, you simply can send an empty string here $numSent = wireMail($userEmail, $from, $subject, $textBody); }); ?> Link to comment Share on other sites More sharing options...
tpr Posted January 30, 2016 Share Posted January 30, 2016 There is no placeholder in your sprintf function, add %s. Also, the URL won't be clickable in this way. Plus you should use httpUrl instead to have an absolute URL in the email. 3 Link to comment Share on other sites More sharing options...
BitPoet Posted January 30, 2016 Share Posted January 30, 2016 Edited away my reply since tpr said it all and better. 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