BP_XProfile_Field::delete( boolean $delete_data = false )
Delete a profile field.
Description
Parameters
- $delete_data
-
(Optional) Whether or not to delete data.
Default value: false
Return
(boolean)
Source
File: bp-xprofile/classes/class-bp-xprofile-field.php
370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 | public function delete ( $delete_data = false ) { global $wpdb ; // 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; } /** * Fires before the current field instance gets deleted. * * @since BuddyPress 3.0.0 * * @param BP_XProfile_Field $this Current instance of the field being deleted. Passed by reference. * @param bool $delete_data Whether or not to delete data. */ do_action_ref_array( 'xprofile_field_before_delete' , array ( & $this , $delete_data ) ); $bp = buddypress(); $sql = $wpdb ->prepare( "DELETE FROM {$bp->profile->table_name_fields} WHERE id = %d OR parent_id = %d" , $this ->id, $this ->id ); if ( ! $wpdb ->query( $sql ) ) { return false; } // Delete all metadata for this field. bp_xprofile_delete_meta( $this ->id, 'field' ); // Delete the data in the DB for this field. if ( true === $delete_data ) { BP_XProfile_ProfileData::delete_for_field( $this ->id ); } /** * Fires after the current field instance gets deleted. * * @since BuddyPress 3.0.0 * * @param BP_XProfile_Field $this Current instance of the field being deleted. Passed by reference. * @param bool $delete_data Whether or not to delete data. */ do_action_ref_array( 'xprofile_field_after_delete' , array ( & $this , $delete_data ) ); 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.