WP_User::__set() WordPress Method

The WP_User::__set() method allows you to set various user properties, such as the user's password, email address, and display name. This method is useful for updating user information in your Wordpress site.

WP_User::__set( string $key, mixed $value ) #

Magic method for setting custom user fields.


Description

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


Top ↑

Parameters

$key

(string)(Required)User meta key.

$value

(mixed)(Required)User meta value.


Top ↑

Source

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

	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;
	}


Top ↑

Changelog

Changelog
VersionDescription
3.3.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.