Skip to:
Content
Pages
Categories
Search
Top
Bottom

disable buddypress email sending for custom role?


  • andrew55
    Participant

    @andrew55

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

    It’s easy for us to assign these members a custom role. Is there a way to prevent BuddyPress 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 BuddyPress from sending of all emails for users who have specific custom role?

    Thanks for any suggestions!

Viewing 1 replies (of 1 total)

  • andrew55
    Participant

    @andrew55

    Robin W over at bbPress was kind enough to provide this filter for functions.php:

    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 ;
    }

    Used with a custom role, it works great at preventing emails from going out from bbPress.

    Of course, BuddyPress sends out several emails (friend request, private messages, etc).

    Any ideas on how I can modify the filter above to prevent sending of BuddyPress emails to user if they have a custom role enabled? Even a place to go where I might find some ideas to work with?

    Thanks for any suggestions.

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