Skip to:
Content

BuddyPress.org

Ticket #5018: 5018.01.patch

File 5018.01.patch, 2.7 KB (added by r-a-y, 12 years ago)
  • bp-groups/bp-groups-cache.php

    add_action( 'bp_groups_delete_group', 'bp_groups_clear_group_members_caches', 10 
    9494function groups_clear_group_user_object_cache( $group_id, $user_id ) {
    9595        wp_cache_delete( 'bp_total_groups_for_user_' . $user_id, 'bp' );
    9696}
    97 add_action( 'groups_join_group',   'groups_clear_group_user_object_cache', 10, 2 );
    98 add_action( 'groups_leave_group',  'groups_clear_group_user_object_cache', 10, 2 );
    99 add_action( 'groups_ban_member',   'groups_clear_group_user_object_cache', 10, 2 );
    100 add_action( 'groups_unban_member', 'groups_clear_group_user_object_cache', 10, 2 );
     97add_action( 'groups_join_group',    'groups_clear_group_user_object_cache', 10, 2 );
     98add_action( 'groups_leave_group',   'groups_clear_group_user_object_cache', 10, 2 );
     99add_action( 'groups_ban_member',    'groups_clear_group_user_object_cache', 10, 2 );
     100add_action( 'groups_unban_member',  'groups_clear_group_user_object_cache', 10, 2 );
     101add_action( 'groups_uninvite_user', 'groups_clear_group_user_object_cache', 10, 2 );
     102add_action( 'groups_remove_member', 'groups_clear_group_user_object_cache', 10, 2 );
    101103
    102104/* List actions to clear super cached pages on, if super cache is installed */
    103105add_action( 'groups_join_group',                 'bp_core_clear_cache' );
  • bp-groups/bp-groups-functions.php

    function groups_leave_group( $group_id, $user_id = 0 ) { 
    299299        // Modify group member count
    300300        groups_update_groupmeta( $group_id, 'total_member_count', (int) groups_get_groupmeta( $group_id, 'total_member_count') - 1 );
    301301
    302         // Modify user's group memberhip count
    303         bp_update_user_meta( $user_id, 'total_group_count', (int) bp_get_user_meta( $user_id, 'total_group_count', true ) - 1 );
     302        // Modify user's group membership count
     303        bp_update_user_meta( $user_id, 'total_group_count', (int) groups_total_groups_for_user( $user_id ) );
    304304
    305305        /**
    306306         * If the user joined this group less than five minutes ago, remove the
    function groups_join_group( $group_id, $user_id = 0 ) { 
    364364        groups_update_groupmeta( $group_id, 'total_member_count', (int) groups_get_groupmeta( $group_id, 'total_member_count') + 1 );
    365365        groups_update_groupmeta( $group_id, 'last_activity', bp_core_current_time() );
    366366
     367        // Modify user's group membership count
     368        bp_update_user_meta( $user_id, 'total_group_count', (int) groups_total_groups_for_user( $user_id ) );
     369
    367370        do_action( 'groups_join_group', $group_id, $user_id );
    368371
    369372        return true;