Thread Starter
tatof
(@tatof)
Found the “conditionals” extension.
https://bracketspace.com/downloads/notification-conditionals/
Does this work with custom {merge_tags}?
Then I could make a merge tag with data from the user account and cancel the notification if is “true”.
Hi @tatof, thanks!
Yes you can use this extension but if you feel comfortable coding you can suppress the notification programmatically: https://docs.bracketspace.com/notification/developer/notifications/suppressing
You’d just need to find a way to check the user meta.
Could you please spare 15 seconds to write a review here? Thanks!
Thread Starter
tatof
(@tatof)
Hey Kuba,
Thanks! I’m pretty far by now:
This checks if the post author has Enabled “new comments” mail and puts it in a MERGE_TAG
notification_add_global_merge_tag(
new BracketSpace\Notification\Defaults\MergeTag\StringTag( [
'slug' => 'authorCommentNew',
'name' => __( 'Author Comment New', 'textdomain' ),
'resolver' => function( $trigger ) {
$curuser = get_post_field( 'post_author', $trigger->post->ID );
$testthing = get_user_meta( $curuser, 'mail_settings' );
if (in_array("comment_new", $testthing[0])){
$authorCommentNew = 1;
} else {
$authorCommentNew = 0;
}
return $authorCommentNew;
},
])
);
But I want to do the same for the “parent_comment user id” when there is a reply.
I only can’t figure out how to get the {parent_comment_author_user_ID} like you did.
If I can get the parent comment after submitting the reply comment I can make an other merge_tag with the value of that user and cancel or suppress the mail.
I think I need something like:
$trigger->parent_comment_author_user_id->ID
Sure! Going to give you a rating 🙂
PS. I saw you’re busy building a opt-in/out function for users, When will that be done? Kinda building that right now but love to not have to build that.
-
This reply was modified 1 year, 10 months ago by
tatof.
-
This reply was modified 1 year, 10 months ago by
tatof.
-
This reply was modified 1 year, 10 months ago by
tatof.
So close!
Comment reply
trigger has this property: https://github.com/BracketSpace/Notification/blob/develop/class/Defaults/Trigger/Comment/CommentReplied.php#L71
so you’d have to do: $trigger->parent_comment_user_object->ID
The opt-in extension is certainly on the list but we haven’t even started it yet and we have hands full of work in the next two months… I wouldn’t expect it released earlier.
Thread Starter
tatof
(@tatof)
Nice! This works perfectly :D.
So the output of my custom MERGE_TAG is now the user ID (in the notification log).
I can use this in the “Notification : Conditionals” extension right?
If “value” == “0” – Don’t send
If “value” == “1” – Send!
If this works then I don’t need the opt-in plugin!
Correct!
Setup will look like this:
Process this trigger only if
{your_merge_tag} equals 1
It may require some testing with the conditions, depends what’s the merge tag value exactly (if string or bool).
Thread Starter
tatof
(@tatof)
Oke thanks, I can figure that out!