XProfile_Field::delete( $args,  $assoc_args )

Delete an XProfile field.


Description Description

Top ↑

OPTIONS OPTIONS

… : ID or IDs for the field. Accepts either the name of the field or a numeric ID.
[–delete-data] : Delete user data for the field as well.
[–yes] : Answer yes to the confirmation message.
## EXAMPLES
$ wp bp xprofile field delete 500 –yes Success: Deleted XProfile field “Field Name” (ID 500).
$ wp bp xprofile field remove 458 –delete-data –yes Success: Deleted XProfile field “Another Field Name” (ID 458).


Source Source

File: cli/src/xprofile-field.php

	public function delete( $args, $assoc_args ) {
		$delete_data = WP_CLI\Utils\get_flag_value( $assoc_args, 'delete-data' );

		WP_CLI::confirm( 'Are you sure you want to delete this field?', $assoc_args );

		parent::_delete( $args, $assoc_args, function( $field_id ) use ( $delete_data ) {
			$field = new \BP_XProfile_Field( $field_id );
			$name  = $field->name;
			$id    = $field->id;

			if ( $field->delete( $delete_data ) ) {
				return array( 'success', sprintf( 'Deleted XProfile field "%s" (ID %d).', $name, $id ) );
			} else {
				return array( 'error', sprintf( 'Failed deleting XProfile field (ID %d).', $field_id ) );
			}
		} );
	}


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.