xprofile_delete_field_data( string $field = '', int $user_id )

Delete XProfile field data.

Description

Parameters

$field

(string) (Optional) Field to delete.

Default value: ''

$user_id

(int) (Required) User ID to delete field from.

Return

(bool) Whether or not the field was deleted.

Source

File: bp-xprofile/bp-xprofile-functions.php

function xprofile_delete_field_data( $field = '', $user_id = 0 ) {

	// Get the field ID.
	if ( is_numeric( $field ) ) {
		$field_id = (int) $field;
	} else {
		$field_id = xprofile_get_field_id_from_name( $field );
	}

	// Bail if field or user ID are empty.
	if ( empty( $field_id ) || empty( $user_id ) ) {
		return false;
	}

	// Get the profile field data to delete.
	$field = new BP_XProfile_ProfileData( $field_id, $user_id );

	// Delete the field data.
	return $field->delete();
}

Changelog

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.