Skip to:
Content

BuddyPress.org

Changeset 9666


Ignore:
Timestamp:
03/31/2015 05:37:52 PM (9 years ago)
Author:
boonebgorges
Message:

Introduce 'before'/'after' hooks in BP_Groups_Member delete() and remove() methods.

These hooks parallel the save() hooks, and provide a better mechanism for
cache invalidation.

See #6327.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-groups/classes/class-bp-groups-member.php

    r9491 r9666  
    356356        global $wpdb;
    357357
     358        /**
     359         * Fires before a member is removed from a group.
     360         *
     361         * @since BuddyPress (2.3.0)
     362         *
     363         * @param BP_Groups_Member Current group membership object.
     364         */
     365        do_action_ref_array( 'groups_member_before_remove', array( $this ) );
     366
    358367        $bp  = buddypress();
    359368        $sql = $wpdb->prepare( "DELETE FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id = %d", $this->user_id, $this->group_id );
     
    368377        self::refresh_total_member_count_for_group( $this->group_id );
    369378
     379        /**
     380         * Fires after a member is removed from a group.
     381         *
     382         * @since BuddyPress (2.3.0)
     383         *
     384         * @param BP_Groups_Member Current group membership object.
     385         */
     386        do_action_ref_array( 'groups_member_after_remove', array( $this ) );
     387
    370388        return $result;
    371389    }
     
    407425        global $wpdb;
    408426
     427        /**
     428         * Fires before a group membership is deleted.
     429         *
     430         * @since BuddyPress (2.3.0)
     431         *
     432         * @param int $user_id  ID of the user.
     433         * @param int $group_id ID of the group.
     434         */
     435        do_action( 'bp_groups_member_before_delete', $user_id, $group_id );
     436
    409437        $bp = buddypress();
    410438        $remove = $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id = %d", $user_id, $group_id ) );
     
    415443        // Update the group's member count
    416444        self::refresh_total_member_count_for_group( $group_id );
     445
     446        /**
     447         * Fires after a member is removed from a group.
     448         *
     449         * @since BuddyPress (2.3.0)
     450         *
     451         * @param int $user_id  ID of the user.
     452         * @param int $group_id ID of the group.
     453         */
     454        do_action( 'bp_groups_member_after_delete', $user_id, $group_id );
    417455
    418456        return $remove;
Note: See TracChangeset for help on using the changeset viewer.