W3cubDocs

/WordPress

WP_User::for_site( int $site_id = '' )

Sets the site to operate on. Defaults to the current site.

Parameters

$site_id

(int) (Optional) Site ID to initialize user capabilities for. Default is the current site.

Default value: ''

Source

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

public function for_site( $site_id = '' ) {
		global $wpdb;

		if ( ! empty( $site_id ) ) {
			$this->site_id = absint( $site_id );
		} else {
			$this->site_id = get_current_blog_id();
		}

		$this->cap_key = $wpdb->get_blog_prefix( $this->site_id ) . 'capabilities';

		$this->caps = $this->get_caps_data();

		$this->get_role_caps();
	}

Changelog

Version Description
4.9.0 Introduced.

© 2003–2019 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_user/for_site