BP_XProfile_Group::delete()
Delete a profile field group
Description
Return
(boolean)
Source
File: bp-xprofile/classes/class-bp-xprofile-group.php
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 BuddyPress 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.
if ( ! empty( $this->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 BuddyPress 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;
}
Changelog
| Version | Description |
|---|---|
| BuddyPress 1.1.0 | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.