WP_User::__set()publicWP 3.3.0

Magic method for setting custom user fields.

This method does not update custom fields in the database. It only stores the value on the WP_User instance.

Method of the class: WP_User{}

No Hooks.

Return

null. Nothing (null).

Usage

$WP_User = new WP_User();
$WP_User->__set( $key, $value );
$key(string) (required)
User meta key.
$value(mixed) (required)
User meta value.

Changelog

Since 3.3.0 Introduced.

WP_User::__set() code WP 6.6.2

public function __set( $key, $value ) {
	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>'
			)
		);
		$this->ID = $value;
		return;
	}

	$this->data->$key = $value;
}