+ * Magic method for checking the existence of a certain custom field
+ *
+ * @since 3.3.0
+ */
+ function __isset( $key ) {
+ if ( 'id' == $key ) {
+ _deprecated_argument( 'WP_User->id', '2.1', __( 'Use <code>WP_User->ID</code> instead.' ) );
+ $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 );
+ }
+
+ /**
+ * Magic method for accessing custom fields
+ *
+ * @since 3.3.0
+ */
+ function __get( $key ) {
+ if ( 'id' == $key ) {
+ _deprecated_argument( 'WP_User->id', '2.1', __( 'Use <code>WP_User->ID</code> instead.' ) );
+ 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;
+ }
+
+ /**
+ * Magic method for setting custom fields
+ *
+ * @since 3.3.0
+ */
+ function __set( $key, $value ) {
+ if ( 'id' == $key ) {
+ _deprecated_argument( 'WP_User->id', '2.1', __( 'Use <code>WP_User->ID</code> instead.' ) );
+ $this->ID = $value;
+ return;
+ }
+
+ $this->data->$key = $value;
+ }
+
+ /**
+ * Determine whether the user exists in the database.
+ *
+ * @since 3.4.0
+ * @access public
+ *
+ * @return bool True if user exists in the database, false if not.
+ */
+ function exists() {
+ return ! empty( $this->ID );
+ }
+
+ /**
+ * Retrieve the value of a property or meta key.
+ *
+ * Retrieves from the users and usermeta table.
+ *
+ * @since 3.3.0
+ *
+ * @param string $key Property
+ */
+ function get( $key ) {
+ return $this->__get( $key );
+ }
+
+ /**
+ * Determine whether a property or meta key is set
+ *
+ * Consults the users and usermeta tables.
+ *
+ * @since 3.3.0
+ *
+ * @param string $key Property
+ */
+ function has_prop( $key ) {
+ return $this->__isset( $key );
+ }
+
+ /**
+ * Return an array representation.
+ *
+ * @since 3.5.0
+ *
+ * @return array Array representation.
+ */
+ function to_array() {
+ return get_object_vars( $this->data );
+ }
+
+ /**
+ * Set up capability object properties.