• Resolved aboood343

    (@aboood343)


    Hi there,

    Thanks for the awesome plugin, Is there a way to make the notifications rules like when someone is posting a new topic an email is sent not to the whole users with configured role to receive notifications but limit that to another condition like they have specific value for a user field? “For example when user with country Germany is posting a new topic only users with the same country value to receive the email notification”

    Is that achievable by some customization? So before sending the email adding a condition to check value of the topic creator and the recipients

    Thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter aboood343

    (@aboood343)

    Hope I made myself clear enough

    Thread Starter aboood343

    (@aboood343)

    I tried to add the below in the foreach loop in the function get_recipients but no luck

    
    if ( 'topic' === $type ) 
    {
    	$ID = $user->ID;
    	$author_id = bbp_get_topic_author_id( $topic_id );
    	$city_user = xprofile_get_field_data(‘City’, $author_id);
    	$city_author = xprofile_get_field_data(‘City’, $ID);
    					
    	if ( $city_user === $city_author )
    	{
    		$recipients[$user->ID] = $user; // make sure unique recipients
    	}
    }
    else
    {
            $recipients[$user->ID] = $user; // make sure unique recipients
    }
    

    any ideas please?

    • This reply was modified 7 years, 7 months ago by aboood343. Reason: updating the code layout
    Plugin Author useStrict

    (@usestrict)

    Hi aboood343,

    Sorry for the delay. I didn’t get a few notifications of new messages – probably due to the forum update.

    The best thing you can do is to hook into a filter instead of modifying the plugin.

    The filters you want are: bbpress_topic_notify_recipients and bbpress_reply_notify_recipients.

    // For topics
    $recipients = apply_filters( 'bbpress_topic_notify_recipients', $recipients, $topic_id, $forum_id );
    
    // For replies
    $recipients = apply_filters( 'bbpress_reply_notify_recipients', $recipients, $reply_id, $topic_id, $forum_id );
    

    You’ll be able to override the whole recipients list that way.

    Cheers,
    Vinny

    • This reply was modified 7 years, 7 months ago by useStrict.
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Send to members depending on user field’ is closed to new replies.