Last active
April 25, 2026 20:51
-
-
Save contemplate/4fa9ada2c6bdcabd18d281054f199b3f to your computer and use it in GitHub Desktop.
BPGES integration with BuddyBoss
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Prevent duplicate emails between BPGES and BuddyBoss Group Subscriptions. | |
| * | |
| * The problem: Both systems send emails on group activity. | |
| * - BuddyBoss hooks bp_groups_posted_update → sends 'groups-new-activity' immediately | |
| * - BPGES hooks bp_activity_after_save → sends 'bp-ges-single' immediately for supersub/sub users | |
| * Result: Users on "All Email" or "New Topics" get two emails per post. | |
| * | |
| * The solution: Let each system handle what it does best. | |
| * - 'supersub' (All Email) → BuddyBoss sends immediate email, BPGES is blocked | |
| * - 'sub' (New Topics) → BuddyBoss sends immediate email, BPGES is blocked | |
| * - 'dig' (Daily Digest) → BPGES handles digest, BuddyBoss is blocked | |
| * - 'sum' (Weekly Summary) → BPGES handles summary, BuddyBoss is blocked | |
| * - 'no' (No Email) → Both are blocked | |
| * | |
| * Web/app notifications from BuddyBoss are NOT affected. | |
| * | |
| * Filter references in BuddyBoss source: | |
| * bb_send_subscribed_group_email_notifications | |
| * → bp-groups/classes/class-bp-groups-notification.php | |
| * inside bb_send_subscribed_group_notifications() | |
| * | |
| * Filter references in BPGES source: | |
| * bp_ass_send_activity_notification_for_user | |
| * → bp-activity-subscription-functions.php | |
| * inside ass_group_notification_activity() | |
| */ | |
| // ────────────────────────────────────────────────────────────────────── | |
| // 1. Block BuddyBoss immediate emails for digest, summary, and no-email users. | |
| // Only allow BuddyBoss emails when BPGES is set to All Email or New Topics. | |
| // ────────────────────────────────────────────────────────────────────── | |
| add_filter( 'bb_send_subscribed_group_email_notifications', 'bpges_block_bb_group_sub_emails', 10, 2 ); | |
| function bpges_block_bb_group_sub_emails( $send_mail, $args ) { | |
| if ( false === $send_mail ) { | |
| return $send_mail; | |
| } | |
| if ( ! function_exists( 'ass_get_group_subscription_status' ) ) { | |
| return $send_mail; | |
| } | |
| $user_id = ! empty( $args['recipient_user_id'] ) ? (int) $args['recipient_user_id'] : 0; | |
| $group_id = ! empty( $args['group_id'] ) ? (int) $args['group_id'] : 0; | |
| if ( empty( $user_id ) || empty( $group_id ) ) { | |
| return $send_mail; | |
| } | |
| $sub_status = ass_get_group_subscription_status( $user_id, $group_id ); | |
| // Only allow BuddyBoss immediate emails for instant-notification users. | |
| $allow_immediate = array( 'supersub', 'sub' ); | |
| if ( ! in_array( $sub_status, $allow_immediate, true ) ) { | |
| return false; | |
| } | |
| return $send_mail; | |
| } | |
| // ────────────────────────────────────────────────────────────────────── | |
| // 2. Block BPGES immediate emails for supersub/sub users when BuddyBoss | |
| // Group Subscriptions is active (to prevent duplicates). | |
| // BPGES still handles digest and summary — those are unaffected. | |
| // ────────────────────────────────────────────────────────────────────── | |
| add_filter( 'bp_ass_send_activity_notification_for_user', 'block_bpges_immediate_when_bb_subscriptions_active', 10, 4 ); | |
| function block_bpges_immediate_when_bb_subscriptions_active( $send_immediately, $activity, $user_id, $subscription_type ) { | |
| // Only intervene if BuddyBoss Group Subscriptions is active. | |
| if ( ! function_exists( 'bb_is_enabled_subscription' ) || ! bb_is_enabled_subscription( 'group' ) ) { | |
| return $send_immediately; | |
| } | |
| // Only block immediate sends — digest/summary queueing is separate. | |
| if ( false === $send_immediately ) { | |
| return $send_immediately; | |
| } | |
| // For supersub and sub users, BuddyBoss handles the immediate email. | |
| // Block BPGES from sending a duplicate. | |
| if ( in_array( $subscription_type, array( 'supersub', 'sub' ), true ) ) { | |
| return false; | |
| } | |
| return $send_immediately; | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
BPGES + BuddyBoss Group Subscription Email Deduplication
The Problem
Both systems send emails on group activity:
bp_groups_posted_update→ sendsgroups-new-activityimmediatelybp_activity_after_save→ sendsbp-ges-singleimmediately for supersub/sub usersResult: Users on "All Email" or "New Topics" get two emails per post.
The Solution
Let each system handle what it does best. BuddyBoss handles immediate emails (nicer templates). BPGES handles digests and summaries (BuddyBoss doesn't have this feature).
supersubsubdigsumnoFilters Used
Filter 1:
bb_send_subscribed_group_email_notificationsbp-groups/classes/class-bp-groups-notification.php→bb_send_subscribed_group_notifications()dig,sum, andnousersFilter 2:
bp_ass_send_activity_notification_for_userbp-activity-subscription-functions.php→ass_group_notification_activity()supersubandsubusers (BuddyBoss handles these instead)Related Issues