Support » Plugin: Notification - Custom Notifications and Alerts for WordPress » Disable notifications for some users (code)

  • Resolved tatof



    Love the plugin! Works perfectly.
    I’m building a custom “social” platform and users have to be able to “enable/disable” mails they recieve.
    It’s easy to make a checkbox and save the setting but is there a webhook or someting I can Unhook so the custom notification will not be send after the user updates his setting?

    I’ve tried to find the “trigger” for comment added & comment replied so I can copy them in my own custom trigger. But I can’t find the source./

    Could you help me? 🙂

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter tatof


    Found the “conditionals” extension.

    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”.

    Plugin Author Kuba Mikita


    Hi @tatof, thanks!

    Yes you can use this extension but if you feel comfortable coding you can suppress the notification programmatically:

    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


    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

        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:

    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.
    Plugin Author Kuba Mikita


    So close!

    Comment reply trigger has this property:

    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


    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!

    Plugin Author Kuba Mikita



    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


    Oke thanks, I can figure that out!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Disable notifications for some users (code)’ is closed to new replies.