WP_User::init()publicWP 3.3.0

Sets up object properties, including capabilities.

Method of the class: WP_User{}

No Hooks.

Return

null. Nothing (null).

Usage

$WP_User = new WP_User();
$WP_User->init( $data, $site_id );
$data(object) (required)
User DB row object.
$site_id(int)
The site ID to initialize for.
Default: ''

Changelog

Since 3.3.0 Introduced.

WP_User::init() code WP 6.6.2

public function init( $data, $site_id = '' ) {
	if ( ! isset( $data->ID ) ) {
		$data->ID = 0;
	}
	$this->data = $data;
	$this->ID   = (int) $data->ID;

	$this->for_site( $site_id );
}