public function delete($delete_data = false) { global $wpdb, $bp; // Prevent deletion if no ID is present // Prevent deletion by url when can_delete is false. // Prevent deletion of option 1 since this invalidates fields with options. if (empty($this->id) || empty($this->can_delete) || $this->parent_id && $this->option_order == 1) { return false; } if (!$wpdb->query($wpdb->prepare("DELETE FROM {$bp->profile->table_name_fields} WHERE id = %d OR parent_id = %d", $this->id, $this->id))) { return false; } // delete the data in the DB for this field if (true === $delete_data) { BP_XProfile_ProfileData::delete_for_field($this->id); } return true; }
function delete() { global $wpdb, $bp; if ( !$this->id || // Prevent deletion by url when can_delete is false. !$this->can_delete || // Prevent deletion of option 1 since this invalidates fields with options. ( $this->parent_id && $this->option_order == 1 ) ) return false; if ( !$wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->profile->table_name_fields} WHERE id = %d OR parent_id = %d", $this->id, $this->id ) ) ) return false; // delete the data in the DB for this field BP_XProfile_ProfileData::delete_for_field($this->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; }
function delete() { global $wpdb, $bp; if (!$this->id) { return false; } if (!$wpdb->query($wpdb->prepare("DELETE FROM {$bp->profile->table_name_fields} WHERE id = %d OR parent_id = %d", $this->id, $this->id))) { return false; } // delete the data in the DB for this field BP_XProfile_ProfileData::delete_for_field($this->id); return true; }
function delete() { global $nxtdb, $bp; if (!$this->id || !$this->can_delete || $this->parent_id && $this->option_order == 1) { return false; } if (!$nxtdb->query($nxtdb->prepare("DELETE FROM {$bp->profile->table_name_fields} WHERE id = %d OR parent_id = %d", $this->id, $this->id))) { return false; } /* delete the data in the DB for this field */ BP_XProfile_ProfileData::delete_for_field($this->id); return true; }