encho Posted April 4, 2013 Share Posted April 4, 2013 I would like to know if there's a way to customize the outgoing message (sent to moderator/administrator of comments) when comment is posted? I would like that message to: 1. Have different subject 2. Contain the link to easily approve the comment (one-click), or at least bring you to page/edit where you can edit the page in question.. Not sure if possible at all, but all inputs appreciated. Also, I would like someone to give me working example of using "requireSecurityField" option when rendering the comment form (as I am not javascript guru). Thanks all! Link to comment Share on other sites More sharing options...
Radek Posted April 4, 2013 Share Posted April 4, 2013 I would like to know if there's a way to customize the outgoing message (sent to moderator/administrator of comments) when comment is posted? I would like that message to: 1. Have different subject 2. Contain the link to easily approve the comment (one-click), or at least bring you to page/edit where you can edit the page in question.. Not sure if possible at all, but all inputs appreciated. Also, I would like someone to give me working example of using "requireSecurityField" option when rendering the comment form (as I am not javascript guru). Thanks all! Hi, i looked to module code and seems like dont support own email format now. Mail localization will be supported. About SecurityFiled: Form render in template must have 'requireSecurityField' => 'security_field' $outSendForm = $page->comments->renderForm(array('requireSecurityField' => 'security_field')); And needed javascript is here: <script type="text/javascript" charset="utf-8"> $(document).ready(function(){ var $input = "<input type='hidden' name='security_field' value='1' />"; $("#CommentForm form").append($input); $("#CommentForm").show(); }); </script> Comments documentation. 2 Link to comment Share on other sites More sharing options...
renobird Posted May 6, 2013 Share Posted May 6, 2013 I could really use this as well. Any other ways to customize the outgoing message in the meantime? Link to comment Share on other sites More sharing options...
ryan Posted May 9, 2013 Share Posted May 9, 2013 One way you could do it would be to make the FieldtypeComments::sendNotificationEmail method hookable. If you want to add 3 underscores before that function name (in /wire/modules/Fieldtype/FieldtypeComments.module), I'll make the same change here. From there, it should be hookable. In this case, you'd probably want to override/replace the method completely. To do this, your hook function would populate the $event->replace=true; Using PW 2.3 dev syntax: wire()->addHookBefore('FieldtypeComments::sendNotificationEmail', function(HookEvent $event) { $event->replace = true; $page = $event->arguments(1); $field = $event->arguments(2); $comment = $event->arguments(3); $subject = "New Comment Posted!"; $body = "A new comment was posted to $page->httpUrl by $comment->cite: $comment->text"; mail($field->notificationEmail, $subject, $body); }); 2 Link to comment Share on other sites More sharing options...
renobird Posted May 10, 2013 Share Posted May 10, 2013 Hi Ryan, This seems great! I'll give it a test tomorrow. For the project I'm working on I needed to mimicking some functionality from Basecamp where users can select people to notify of a new comment via checkboxes. In this case it's a list of 5-8 people who have a particular role. In order to make it work, I needed multiple custom messages based on $page->template — while leaving the default message in place for existing pages with comments. I also needed an additional field to store the list of email address that need notified of the comment. I happened across this thread and decided to give it a shot. It was pretty easy to add the additional field to the DB and update the module in a few places. I now have an additional field ($comment->notifications) that is output as a hidden field and populated with email addresses via JS. The security concerns are low since all users are trusted and authenticated. The whole thing is pretty specific to the needs of this project, but (as always) I was shocked at how easy it was to get working. 1 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