Jump to content

Recommended Posts

Posted

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

Posted
$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.

  • Like 1
  • 2 weeks later...
Posted

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);
});
?>
Posted

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.

  • Like 3

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...