Changeset 7179
- Timestamp:
- 06/07/2013 01:31:27 AM (12 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-groups/bp-groups-classes.php
r7147 r7179 1223 1223 $this->id = $wpdb->insert_id; 1224 1224 1225 // Update the user's group count 1226 self::refresh_total_group_count_for_user( $this->user_id ); 1227 1225 1228 do_action_ref_array( 'groups_member_after_save', array( &$this ) ); 1226 1229 … … 1277 1280 1278 1281 groups_update_groupmeta( $this->group_id, 'total_member_count', ( (int) groups_get_groupmeta( $this->group_id, 'total_member_count' ) + 1 ) ); 1279 bp_update_user_meta( $this->user_id, 'total_group_count', (int) bp_get_user_meta( $this->user_id, 'total_group_count', true ) + 1 );1280 1282 1281 1283 return $this->save(); … … 1287 1289 $this->is_confirmed = 1; 1288 1290 $this->date_modified = bp_core_current_time(); 1289 1290 bp_update_user_meta( $this->user_id, 'total_group_count', (int) bp_get_user_meta( $this->user_id, 'total_group_count', true ) + 1 );1291 1291 } 1292 1292 … … 1295 1295 $this->is_confirmed = 1; 1296 1296 $this->date_modified = bp_core_current_time(); 1297 1298 bp_update_user_meta( $this->user_id, 'total_group_count', (int) bp_get_user_meta( $this->user_id, 'total_group_count', true ) + 1 );1299 1297 } 1300 1298 … … 1309 1307 groups_update_groupmeta( $this->group_id, 'total_member_count', ( (int) groups_get_groupmeta( $this->group_id, 'total_member_count' ) - 1 ) ); 1310 1308 1311 $group_count = bp_get_user_meta( $this->user_id, 'total_group_count', true ); 1312 if ( !empty( $group_count ) ) 1313 bp_update_user_meta( $this->user_id, 'total_group_count', (int) $group_count - 1 ); 1309 // Update the user's group count 1310 self::refresh_total_group_count_for_user( $this->user_id ); 1314 1311 1315 1312 return $result; … … 1318 1315 /** Static Methods ********************************************************/ 1319 1316 1317 public static function refresh_total_group_count_for_user( $user_id ) { 1318 bp_update_user_meta( $user_id, 'total_group_count', (int) self::total_group_count( $user_id ) ); 1319 } 1320 1320 1321 function delete( $user_id, $group_id ) { 1321 1322 global $wpdb, $bp; 1322 1323 1323 return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id = %d", $user_id, $group_id ) ); 1324 $remove = $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id = %d", $user_id, $group_id ) ); 1325 1326 // Update the user's group count 1327 self::refresh_total_group_count_for_user( $user_id ); 1328 1329 return $remove; 1324 1330 } 1325 1331 -
trunk/bp-groups/bp-groups-functions.php
r7172 r7179 302 302 // Modify group member count 303 303 groups_update_groupmeta( $group_id, 'total_member_count', (int) groups_get_groupmeta( $group_id, 'total_member_count') - 1 ); 304 305 // Modify user's group memberhip count306 bp_update_user_meta( $user_id, 'total_group_count', (int) bp_get_user_meta( $user_id, 'total_group_count', true ) - 1 );307 304 308 305 /**
Note: See TracChangeset
for help on using the changeset viewer.