Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
03/09/2014 07:37:47 PM (10 years ago)
Author:
boonebgorges
Message:

When demoting a member in a group, delete corresponding promotion notifications

See #5289

Props imath

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-groups/bp-groups-notifications.php

    r8037 r8097  
    556556    if ( bp_is_active( 'notifications' ) ) {
    557557        bp_notifications_delete_all_notifications_by_type( $group_id, buddypress()->groups->id );
    558     }   
     558    }
    559559}
    560560add_action( 'groups_delete_group', 'bp_groups_delete_group_delete_all_notifications', 10 );
     561
     562/**
     563 * When a demotion takes place, delete any corresponding promotion notifications.
     564 *
     565 * @since BuddyPress (2.0.0)
     566 */
     567function bp_groups_delete_promotion_notifications( $user_id = 0, $group_id = 0 ) {
     568    if ( bp_is_active( 'notifications' ) && ! empty( $group_id ) && ! empty( $user_id ) ) {
     569        bp_notifications_delete_notifications_by_item_id( $user_id, $group_id, buddypress()->groups->id, 'member_promoted_to_admin' );
     570        bp_notifications_delete_notifications_by_item_id( $user_id, $group_id, buddypress()->groups->id, 'member_promoted_to_mod' );
     571    }
     572}
     573add_action( 'groups_demoted_member', 'bp_groups_delete_promotion_notifications', 10, 2 );
    561574
    562575/**
Note: See TracChangeset for help on using the changeset viewer.