WordPress at Your Fingertips
function is not described

WP_User::__get() public WP 3.3.0

Magic method for accessing custom fields.

{} It's a method of the class: WP_User{}

No Hooks.

Return

Mixed. Value of the given user meta key (if set). If $key is 'id', the user ID.

Usage

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

Changelog

Since 3.3.0 Introduced.

Code of WP_User::__get() WP 5.8.1

public function __get( $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>'
			)
		);
		return $this->ID;
	}

	if ( isset( $this->data->$key ) ) {
		$value = $this->data->$key;
	} else {
		if ( isset( self::$back_compat_keys[ $key ] ) ) {
			$key = self::$back_compat_keys[ $key ];
		}
		$value = get_user_meta( $this->ID, $key, true );
	}

	if ( $this->filter ) {
		$value = sanitize_user_field( $key, $value, $this->ID, $this->filter );
	}

	return $value;
}