Jump to content

How to hook into comments module to change notificationEmail?


apeisa
 Share

Recommended Posts

I have multiple blogs on site with different authors. I would like to use same comment field, but change the notificationEmail based on which blog got the comment.


Should this https://github.com/ryancramerdesign/ProcessWire/blob/master/wire/modules/Fieldtype/FieldtypeComments/FieldtypeComments.module#L239 be hookable or is there other way to implement this?

Link to comment
Share on other sites

I think that a config option in the core module might make sense here, and I don't usually suggest that but in this case I see it just being a checkbox labelled "email post author when new comments are made" which seems a but much having a whole module for it. In this case it would work for one blog with multiple authors or multiple blogs as well.

To be honest, you'd then want another one to toggle whether the admin email address gets an email with every comment as well as this might then be unnecessary on some sites.

The more I think about it the more options I want to add to the config but then we're getting away from a simple config option :)

  • Like 1
Link to comment
Share on other sites

I was assuming each author has their own account and therefore they would receive those emails instead of/as well as the system admin - I might not be understanding your setup well enough though.



In fact, it's not as simple as I thought as individual authors couldn't moderate just their own comments with the module (assuming you wanted to?) unless you rewrite a chunk of the module and let them have access to the comments manager.

Well that just got more complicated :)

Link to comment
Share on other sites

Antti, I think you should be able to just set that email field before you output your comments. I don't think you'd need any modules or hooks or anything like that. So lets say you had a field on your page called comments_email. You may be able to do something like this:

if($page->comments_email) {
  $commentsField = $fields->get('comments'); 
  $commentsField->notificationEmail = $page->comments_email;
}
echo $page->comments->render();
echo $page->comments->renderForm(); 
  • Like 5
Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

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