function delete()
 {
     global $wpdb, $bp;
     if (!$this->can_delete) {
         return false;
     }
     $sql = $wpdb->prepare("DELETE FROM {$bp->profile->table_name_groups} WHERE id = %d", $this->id);
     if (!$wpdb->query($sql)) {
         return false;
     } else {
         // Now the group is deleted, remove the group's fields.
         if (BP_XProfile_Field::delete_for_group($this->id)) {
             // Now delete all the profile data for the groups fields
             for ($i = 0; $i < count($this->fields); $i++) {
                 BP_XProfile_ProfileData::delete_for_field($this->fields[$i]->id);
             }
         }
         return true;
     }
 }
Example #2
0
 function delete()
 {
     global $wpdb, $bp;
     if (empty($this->can_delete)) {
         return false;
     }
     // Delete field group
     if (!$wpdb->query($wpdb->prepare("DELETE FROM {$bp->profile->table_name_groups} WHERE id = %d", $this->id))) {
         return false;
     } else {
         // Remove the group's fields.
         if (BP_XProfile_Field::delete_for_group($this->id)) {
             // Remove profile data for the groups fields
             for ($i = 0, $count = count($this->fields); $i < $count; ++$i) {
                 BP_XProfile_ProfileData::delete_for_field($this->fields[$i]->id);
             }
         }
         return true;
     }
 }
 /**
  * Delete a profile field group
  *
  * @since 1.1.0
  *
  * @global object  $wpdb
  * @return boolean
  */
 public function delete()
 {
     global $wpdb;
     // Bail if field group cannot be deleted.
     if (empty($this->can_delete)) {
         return false;
     }
     /**
      * Fires before the current group instance gets deleted.
      *
      * @since 2.0.0
      *
      * @param BP_XProfile_Group $this Current instance of the group being deleted. Passed by reference.
      */
     do_action_ref_array('xprofile_group_before_delete', array(&$this));
     $bp = buddypress();
     $sql = $wpdb->prepare("DELETE FROM {$bp->profile->table_name_groups} WHERE id = %d", $this->id);
     $deleted = $wpdb->query($sql);
     // Delete field group.
     if (empty($deleted) || is_wp_error($deleted)) {
         return false;
     }
     // Remove the group's fields.
     if (BP_XProfile_Field::delete_for_group($this->id)) {
         // Remove profile data for the groups fields.
         for ($i = 0, $count = count($this->fields); $i < $count; ++$i) {
             BP_XProfile_ProfileData::delete_for_field($this->fields[$i]->id);
         }
     }
     /**
      * Fires after the current group instance gets deleted.
      *
      * @since 2.0.0
      *
      * @param BP_XProfile_Group $this Current instance of the group being deleted. Passed by reference.
      */
     do_action_ref_array('xprofile_group_after_delete', array(&$this));
     return true;
 }