Closed admin-teametry closed 4 years ago
The code snippet should be placed in file site/config.php
(not site/config/config.php
). If you don't have any other options in that file, it should look like this:
<?php
return [
'hooks' => [
'commentions.add:after' => function ($page, $data) {
try {
kirby()->email([
'from' => 'webserver@example.com',
'to' => 'admin@example.com',
'subject' => 'New comment/webmention on ' . $page->title(),
'body'=> print_r($data, true),
]);
} catch (Exception $error) {
echo $error;
}
}
],
]
@admin-teametry Has this issue been resolved?
No reply in 15 days; assuming not a bug and solved ...happy to reopen when needed.
@admin-teametry I hope you don't mind me pinging you here in a slightly off-topic manner, but I'd like to draw your attention to my update that I am no longer able to maintain the Commentions plugin in the future → details here.
Hi,
I'm a newbie to Kirby and the commentions plugin. I testet the example with
'hooks' => [ 'commentions.add:after' => function ($page, $data) { try { kirby()->email([ 'from' => 'admin@...', 'to' => 'andreas@...', 'subject' => 'New comment/webmention on ' . $page->title(), 'body'=> print_r($data, true), ]); } catch (Exception $error) { echo $error; } } ]
in the hooks.php of your plugin and also in the "site/config/config.php" without success. Testing email with a contact form on my site, sending is successful.
Do I have wrong thinking, because I think your example should work out of the box, correct? Or is it in the wrong place?
Thanks and regards Andreas