Exemplo n.º 1
0
 function delete()
 {
     global $wpdb, $bp;
     // Delete groupmeta for the group
     groups_delete_groupmeta($this->id);
     // Modify group count usermeta for members
     for ($i = 0; $i < count($this->user_dataset); $i++) {
         $user = $this->user_dataset[$i];
         $total_count = get_usermeta($user->user_id, 'total_group_count');
         if ($total_count != '') {
             update_usermeta($user->user_id, 'total_group_count', (int) $total_count - 1);
         }
         // Now delete the group member record
         BP_Groups_Member::delete($user->user_id, $this->id, false);
     }
     // Delete the wire posts for this group if the wire is installed
     if (function_exists('bp_wire_install')) {
         BP_Wire_Post::delete_all_for_item($this->id, $bp->groups->table_name_wire);
     }
     // Finally remove the group entry from the DB
     if (!$wpdb->query($wpdb->prepare("DELETE FROM {$bp->groups->table_name} WHERE id = %d", $this->id))) {
         return false;
     }
     return true;
 }