xprofile_admin_delete_field( int $field_id, string $field_type = 'field', bool $delete_data = false )
Handles the deletion of a profile field (or field option).
Description
Parameters
- $field_id
-
(int) (Required) The field to delete.
- $field_type
-
(string) (Optional) The type of field being deleted.
Default value: 'field'
- $delete_data
-
(bool) (Optional) Should the field data be deleted too.
Default value: false
Source
File: bp-xprofile/bp-xprofile-admin.php
function xprofile_admin_delete_field( $field_id, $field_type = 'field', $delete_data = false ) { global $message, $type; // Switch type to 'option' if type is not 'field'. // @todo trust this param. $field_type = ( 'field' == $field_type ) ? __( 'field', 'buddyboss' ) : __( 'option', 'buddyboss' ); $field = xprofile_get_field( $field_id ); if ( !$field->delete( (bool) $delete_data ) ) { $message = sprintf( __( 'There was an error deleting the %s. Please try again.', 'buddyboss' ), $field_type ); $type = 'error'; } else { $message = sprintf( __( 'The %s was deleted successfully!', 'buddyboss' ), $field_type ); $type = 'success'; /** * Fires at the end of the field deletion process, if successful. * * @since BuddyPress 1.0.0 * * @param BP_XProfile_Field $field Current BP_XProfile_Field object. */ do_action( 'xprofile_fields_deleted_field', $field ); } xprofile_admin_screen( $message, $type ); }
Changelog
Version | Description |
---|---|
BuddyPress 1.0.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.