WP_User::__unset()publicWP 4.4.0

Magic method for unsetting a certain custom field.

Method of the class: WP_User{}

No Hooks.

Return

null. Nothing (null).

Usage

$WP_User = new WP_User();
$WP_User->__unset( $key );
$key(string) (required)
User meta key to unset.

Changelog

Since 4.4.0 Introduced.

WP_User::__unset() code WP 6.6.2

public function __unset( $key ) {
	if ( 'id' === $key ) {
		_deprecated_argument(
			'WP_User->id',
			'2.1.0',
			sprintf(
				/* translators: %s: WP_User->ID */
				__( 'Use %s instead.' ),
				'<code>WP_User->ID</code>'
			)
		);
	}

	if ( isset( $this->data->$key ) ) {
		unset( $this->data->$key );
	}

	if ( isset( self::$back_compat_keys[ $key ] ) ) {
		unset( self::$back_compat_keys[ $key ] );
	}
}