Skip to:
Content
Pages
Categories
Search
Top
Bottom

disable bbp email sending for custom role?


  • andrew55
    Participant

    @andrew55

    We use a membership script integrated with WP and BBP. When users unsubscribe from emails in script, they still get email notifications from bbp (topic replies, etc). This is bad.

    It’s easy for us to mass-assign these members to a custom role. Is there a way to prevent bbp from sending emails to these users who have this custom role?

    I see here that you can create functions for creating new capabilities (for User Role Editor plugin):

    User Role Editor WordPress plugin – Change roles easily

    Is there a function, or another method I can use to prevent bbp from sending of all emails for users who have specific custom role?

    Thanks for any suggestions!

Viewing 6 replies - 1 through 6 (of 6 total)

  • Robin W
    Moderator

    @robin-w

    If you know when a user does this then if you install

    bbP Toolkit

    you can go to users>user>subscriptions and unassign them from all forums and topics with a couple of clicks


    andrew55
    Participant

    @andrew55

    Robin, thank you very much for the reply.

    We do have dozens and dozens of unsubscribes a week, sometimes more, due to the size of our community. It would take too much to adjust settings for users individually.

    I did check out plugin. In description of plugin, it says “No email sending to blocked users”

    This could be promising. I installed it but don’t see a setting for this feature. Maybe plugin does this automatically? I will try to find out from plugin author.

    I was thinking I could give users I need to block a WP role in membership script such as “unsubscribe”

    Then, I could easily set all these users to “blocked” as bbp role (through mass action). If emails don’t go out to blocked users, this might work.


    Robin W
    Moderator

    @robin-w

    ok let me look later to see if there is an easy filter we can apply


    andrew55
    Participant

    @andrew55

    Thank you very much!


    Robin W
    Moderator

    @robin-w

    ok, this is untested for functionality, but doesn’t error

    add_filter( 'bbp_get_topic_subscribers', 'rew_filter_subscrbers' );
    add_filter( 'bbp_get_forum_subscribers', 'rew_filter_subscrbers' );
    
    function rew_filter_subscribers ($users) {
    	$role = 'my_custom_role' ;
    	$filtered_ids = array();
    	foreach ( (array) $users as $user_id ) {
    		$user_info = get_userdata($user_id);
    		$user_roles = $user_info->roles ;
    		if (!in_array ($role, $user_roles)) {
    			array_push($filtered_IDs, $user_id);
    		}
    	
    	}
    return $filtered_ids ;
    }

    Do you know how to put this in to your child theme’s functions file?

    If so you will need to change my_custom_role in this line

    $role = 'my_custom_role' ;

    to the role name that you are using

    If you don’t know how to use functions file, then come back


    andrew55
    Participant

    @andrew55

    I tested and it seems to work great. Thank you very much.

    I think this will help greatly.

Viewing 6 replies - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.
Skip to toolbar