Open romainpoirier opened 1 year ago
That's because requireModeration
is false
, so you won't receive moderator emails. The status
of a comment will be automatically set to approved
instead of pending
, despite the value of notificationModeratorEnabled
.
Sorry, my question was not clear and complete: I don't need moderation, comments have to be published immediately. However, I still need the notifications to be sent for both moderators and public users.
How can I send moderator notifications even if comments are set automatically to true
? I want them to be notified when there's a new comment, but the comment should be displayed without moderation.
Furthermore, independently of moderation, I need that every user get a notification when its comment gets replies: this should be independent of moderation, and isn't working in my case.
In the setup previously copied, at least notificationReplyEnabled
, notificationSubscribeAuto
and notificationSubscribeDefault
are still not sending emails to public users as expected while set to true
.
Despite requireModeration
set to true
doesn't fit what I'm looking for (because I need direct publish), I tried it this test scenario:
Save
the comment to Approved
in the CP;At step 1.
, I get this in the comments
logs:
[INFO] Not sending reply or author notification - marked as pending (to be moderated).
While notificationModeratorApprovedEnabled
setting is also set to true
.
Can you confirm that I should not expect an email notification at this step?
At step 3.
I get this in the comments
logs:
[INFO] Prepare Moderator Notifications.
[ERROR] Error rendering email template: Variable "language" does not exist.
[INFO] Email sent successfully to moderator (user@xxx.com)
[INFO] Prepare Admin Notifications.
[ERROR] Error rendering email template: Variable "language" does not exist.
[INFO] Email sent successfully to admin (moderator@xxx.com)
[INFO] Request context:
$_GET = [
'p' => 'admin/actions/queue/run'
'site' => 'fr'
'v' => '1672389045776'
]
Despite the Email sent successfully
infos, emails are not sent (I anonymized the address in my example for confidentiality).
I can't also fix the Error rendering email template: Variable "language" does not exist.
error, as my 'templateEmail' => ''
setting is set to default. Commenting this line doesn't change anything.
FYI, no custom HTML Email Template
in set in my Email Settings
(admin/settings/email
), and I don't use the language
variable in the System Messages
content (/admin/utilities/system-messages
).
I have also tried to uninstall and re-install the Comments plugin from scratch, and still gets the same error. FYI, when using the Uninstall
> Remove from Plugins
(/admin/settings/plugins
) feature, and if I leave comments before the uninstall, there're appearing again after the re-install and I can't delete them. They are appearing while the craft_comments_
tables were deleted by the uninstallation. I found their ID that I deleted manually from the craft_elements
and craft_elements_sites
tables, but the comments are still showing up (and return a 404 on click).
I have re-installed the prod DB in my local env, and now the expected emails are sent.
After looking up the difference, I finally found that this is the Use Queue for Notifications
setting (admin/comments/settings
) enabled that is blocking the emails.
FYI, this is the log I now get when this setting is disabled:
[INFO] Moderator Notifications disabled.
[INFO] Prepare Author Notifications.
[INFO] Cannot send element author notification: Commenter #1 same as author #1.
[INFO] Prepare Reply Notifications.
[INFO] Email sent successfully comment author (author@xxx.com)
[INFO] Prepare Subscribe Notifications.
[INFO] Email sent successfully to subscriber (subscriber@xxx.com)
[INFO] Prepare Admin Notifications.
[INFO] Email sent successfully to admin (admin@xxx.com)
And this is what I only get in the log when this setting is enabled (and is not sending the emails as expected):
[INFO] Moderator Notifications disabled.
Please can you fix this? If it's disabled, the submit of a comment takes a bit too much time because of the multiples emails directly sent.
By the way, why is it the only setting that we can't set from the config/comments.php
file?
How can I send moderator notifications even if comments are set automatically to true? I want them to be notified when there's a new comment, but the comment should be displayed without moderation.
At the moment, this isn't possible. In my mind, there's no need for any moderator notification as moderation isn't enabled. These notifications are geared to be "actionable" (the moderator needs to moderate the comment).
Furthermore, independently of moderation, I need that every user get a notification when its comment gets replies: this should be independent of moderation, and isn't working in my case.
This should work regardless of moderation settings, as you describe. This is controlled by notificationReplyEnabled
. The only logic for sending this is if moderation is disabled and notificationReplyEnabled
is enabled and you're replying to a comment. Any other checks will be logged (you won't get a notification when replying to your own comment, etc).
I can't also fix the Error rendering email template: Variable "language" does not exist. error, as my 'templateEmail' => '' setting is set to default. Commenting this line doesn't change anything.
This was just fixed in 2.0.5
After looking up the difference, I finally found that this is the Use Queue for Notifications setting (admin/comments/settings) enabled that is blocking the emails.
Glad you've got your emails working. Using the queue should be no different - provided you've either got a queue processing setup, or are visiting the control panel to trigger the queue sending. It's working on my end to send emails via the queue (which is recommended, but not the default to prevent a breaking change)
By the way, why is it the only setting that we can't set from the config/comments.php file?
You can! Looks like it was just missing from the docs.
At the moment, this isn't possible. In my mind, there's no need for any moderator notification as moderation isn't enabled. These notifications are geared to be "actionable" (the moderator needs to moderate the comment).
In my case, the comments are used in a professional area, where's there's not so much activity, and where users and safe users (their account are created by admins). There's no need for moderation, but the moderators/admins would like to be informed each time a user is commenting something.
I was finally able to send the intended notifications using this:
use Craft;
use craft\elements\User;
$moderators = [];
foreach (User::find()->group('moderators')->all() as $user) {
$moderators[] = [
'email' => $user->email,
'enabled' => true
];
}
'notificationModeratorApprovedEnabled' => false,
'notificationAdmins' => $moderators,
'notificationAdminEnabled' => true,
Thank you for all the other points, I can confirm that now I can make working everything as expected.
Describe the bug
When replying to comments, notifications are not sent while moderator Notifications are enabled.
The log is not very explicit:
[INFO] Moderator Notifications disabled.
I can confirm that other Craft system emails are sent normally, and that
$event->isValid = false
(as discussed in #273) is not added.Here's the content of my
config/comments.php
file:As you can see, moderation (
requireModeration
) is disabled, and auto-subscribe (notificationSubscribeAuto
) is enabled.Steps to reproduce
config/comments.php
) as describedCraft CMS version
4.3.5
Plugin version
2.0.4
Multi-site?
Yes
Additional context
No response