WP_User::__isset( string $key )

Magic method for checking the existence of a certain custom field.


Description Description


Parameters Parameters

$key

(string) (Required) User meta key to check if set.


Top ↑

Return Return

(bool) Whether the given user meta key is set.


Top ↑

Source Source

File: wp-includes/class-wp-user.php

	public function __isset( $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>'
				)
			);
			$key = 'ID';
		}

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

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

		return metadata_exists( 'user', $this->ID, $key );
	}

Top ↑

Changelog Changelog

Changelog
Version Description
3.3.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

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