XProfile_Data::delete( $args,  $assoc_args )

Delete XProfile data for a user.


Description Description

Top ↑

OPTIONS OPTIONS

–user-id= : Identifier for the user. Accepts either a user_login or a numeric ID.

[–field-id=] : Identifier for the field. Accepts either the name of the field or a numeric ID.

[–delete-all] : Delete all data for the user.

[–yes] : Answer yes to the confirmation message.

Top ↑

EXAMPLES EXAMPLES

$ wp bp xprofile data delete --user-id=45 --field-id=120 --yes
Success: XProfile data removed.

$ wp bp xprofile data remove --user-id=user_test --delete-all --yes
Success: XProfile data removed.

Source Source

File: cli/src/xprofile-data.php

	public function delete( $args, $assoc_args ) {
		$user = $this->get_user_id_from_identifier( $assoc_args['user-id'] );

		if ( ! isset( $assoc_args['field-id'] ) && ! isset( $assoc_args['delete-all'] ) ) {
			WP_CLI::error( 'Either --field-id or --delete-all must be provided.' );
		}

		if ( isset( $assoc_args['delete-all'] ) ) {
			WP_CLI::confirm( sprintf( 'Are you sure you want to delete all XProfile data for the user %s (#%d)?', $user->user_login, $user->ID ), $assoc_args );

			xprofile_remove_data( $user->ID );
			WP_CLI::success( 'XProfile data removed.' );
		} else {
			WP_CLI::confirm( 'Are you sure you want to delete that?', $assoc_args );

			if ( xprofile_delete_field_data( $assoc_args['field-id'], $user->ID ) ) {
				WP_CLI::success( 'XProfile data removed.' );
			} else {
				WP_CLI::error( 'Could not delete XProfile data.' );
			}
		}
	}


Top ↑

User Contributed Notes User Contributed Notes

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