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).
Parameters 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 Source
File: bp-xprofile/bp-xprofile-admin.php
function xprofile_admin_delete_field( $field_id, $field_type = 'field', $delete_data = false ) { global $message, $type; check_admin_referer( 'bp_xprofile_delete_field-' . $field_id, 'bp_xprofile_delete_field' ); $mode = ! empty( $_GET['mode'] ) ? sanitize_key( $_GET['mode'] ) : false; // Switch type to 'option' if type is not 'field'. // @todo trust this param. $field_type = ( 'field' == $field_type ) ? __( 'field', 'buddypress' ) : __( 'option', 'buddypress' ); // Display the field/option delete confirmation screen. if ( in_array( $mode, array( 'delete_field', 'delete_option' ) ) ) { xprofile_admin_delete_field_screen( $field_id, $field_type ); // Handle the deletion of field } else { $field = xprofile_get_field( $field_id, null, false ); if ( !$field->delete( (bool) $delete_data ) ) { /* translators: %s: the field type */ $message = sprintf( __( 'There was an error deleting the %s. Please try again.', 'buddypress' ), $field_type ); $type = 'error'; } else { /* translators: %s: the field type */ $message = sprintf( __( 'The %s was deleted successfully!', 'buddypress' ), $field_type ); $type = 'success'; /** * Fires at the end of the field deletion process, if successful. * * @since 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 ); } }
Expand full source code Collapse full source code View on Trac
Changelog Changelog
Version | Description |
---|---|
1.0.0 | Introduced. |