WordPress.org

Support

Support » Plugins and Hacks » BuddyPress Group Email Subscription » [Plugin: BuddyPress Group Email Subscription] Duplicates

[Plugin: BuddyPress Group Email Subscription] Duplicates

Viewing 3 replies - 1 through 3 (of 3 total)
  • if anyone needs help with this… it looks like it was due to it using the activity hooks… I’ve changed it to using the bb_new_post filter….

    Replace everything between

    //
    // !SEND EMAIL UPDATES FOR FORUM TOPICS AND POSTS
    //

    and

    // The email notification function for all other activity
    function ass_group_notification_activity( $content ) {

    with

    add_filter('bb_new_post', 'ass_group_notification_forum_changes');
    function ass_group_notification_forum_changes($post_id) {
    	global $bp;
    
    	/* Check to see if user has been registered long enough */
    	if (!ass_registered_long_enough($bp -> loggedin_user -> id))
    		return;
    
    	$post = bb_get_post($post_id);
    	$forum_id = $post -> forum_id;
    
    	$topic = get_topic($post -> topic_id);
    
    	$group = groups_get_group(array('group_id' => $bp -> groups -> current_group -> id));
    	$current_user_info = get_userdata($post -> poster_id);
    	$primary_link = get_site_url() . "/groups/" . $group -> slug . "/forum/topic/" . $topic -> topic_slug . "/";
    	$is_topic = false;
    	if ($topic -> topic_posts == 1) {
    		$is_topic = true;
    		$action = "started";
    	} else {
    		$action = "replied to";
    		$primary_link .= "?#post-" . $post_id;
    	}
    	$action = $current_user_info -> first_name . " " . $current_user_info -> last_name . " " . $action . " the forum topic " . $topic -> topic_title . " in the group " . $group -> name;
    	$subject = '[' . get_blog_option(BP_ROOT_BLOG, 'blogname') . '] ' . $action;
    	$the_content = html_entity_decode(strip_tags(stripslashes($post -> post_text)), ENT_QUOTES);
    
    	$message = sprintf(__('%s
    
    "%s"
    
    To view or reply to this topic, log in and go to:
    %s
    
    ---------------------
    ', 'bp-ass'), $action . ':', $the_content, $primary_link);
    
    	/* Content footer */
    	$settings_link = $bp -> root_domain . '/' . $bp -> groups -> slug . '/' . $bp -> groups -> current_group -> slug . '/notifications/';
    	$message .= sprintf(__('To disable these notifications please log in and go to: %s', 'bp-ass'), $settings_link);
    
    	$group_id = $group -> id;
    	$subscribed_users = groups_get_groupmeta($group_id, 'ass_subscribed_users');
    	if (!$is_topic) {
    		// pre-load these arrays to reduce db calls in the loop
    		$ass_replies_to_my_topic = ass_user_settings_array('ass_replies_to_my_topic');
    		$ass_replies_after_me_topic = ass_user_settings_array('ass_replies_after_me_topic');
    		$user_topic_status = groups_get_groupmeta($bp -> groups -> current_group -> id, 'ass_user_topic_status_' . $topic -> topic_id);
    		$previous_posters = ass_get_previous_posters($post -> topic_id);
    
    		// consolidate the arrays to speed up processing
    		foreach (array_keys( $previous_posters) as $previous_poster) {
    			if (empty($subscribed_users[$previous_poster]))
    				$subscribed_users[$previous_poster] = 'prev-post';
    		}
    	}
    	foreach ((array)$subscribed_users as $user_id => $group_status) {
    		// Does the author want updates of his own posts?
    		if ($user_id == $bp -> loggedin_user -> id) {
    			if (!ass_self_post_notification()) {
    				continue;
    			}
    		}
    
    		$send_it = false;
    		if ($is_topic) {
    			if ($group_status == 'sub' || $group_status == 'supersub') {
    				$send_it = true;
    			}
    		} else {//Is Just a post
    			$topic_status = isset($user_topic_status[$user_id]) ? $user_topic_status[$user_id] : '';
    
    			if ($topic_status == 'mute')// the topic mute button will override the subscription options below
    				continue;
    
    			if ($group_status == 'sum' && $topic_status != 'sub')// maybe not neccedary, but good to be cautious
    				continue;
    
    			if ($group_status == 'supersub')
    				$send_it = true;
    			elseif ($topic_status == 'sub')
    				$send_it = true;
    			elseif ($topic -> topic_poster == $user_id && isset($ass_replies_to_my_topic[$user_id]) && $ass_replies_to_my_topic[$user_id] != 'no')
    				$send_it = true;
    			elseif ($previous_posters[$user_id] && isset($ass_replies_after_me_topic[$user_id]) && $ass_replies_after_me_topic[$user_id] != 'no')
    				$send_it = true;
    		}
    		if ($send_it) {
    			$notice = "\n" . __('Your email setting for this group is: ', 'bp-ass') . ass_subscribe_translate($group_status);
    			$user = bp_core_get_core_userdata($user_id);
    			// Get the details for the user
    
    			if ($user -> user_email)
    				wp_mail($user -> user_email, $subject, $message . $notice);
    			// Send the email
    		}
    
    		if ($group_status == 'dig' || ($is_topic && $group_status == 'sum')) {
    			ass_digest_record_activity($post_id, $user_id, $group_id, $group_status);
    		}
    
    	}
    
    }

    yes this replaces the new topic and new post actions ….

    Plugin Author r-a-y

    @r-a-y

    Hey Chris,

    Thanks for looking into it! I experienced the same problem as well.

    I’ve created an issue on the Group Email issue tracker:
    https://github.com/boonebgorges/buddypress-group-email-subscription/issues/6

    It appears to be a BP bug.

    Great for you!
    In my case, since I installed the plug in, no one single email has been sent. Anyone knows what I can do? The website is hosted at Godaddy.

    Thanks in advance.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Plugin: BuddyPress Group Email Subscription] Duplicates’ is closed to new replies.
Skip to toolbar