WordPress at a glance
function is not described

WP_User::for_site() public WP 4.9.0

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

{} It's a method of the class: WP_User{}

No Hooks.

Return

````. Null. Nothing.

Usage

$WP_User = new WP_User();
$WP_User->for_site( $site_id );
$site_id(int)
Site ID to initialize user capabilities for.
Default: current site

Notes

  • Global. wpdb. $wpdb WordPress database abstraction object.

Changelog

Since 4.9.0 Introduced.

Code of WP_User::for_site() WP 5.7

<?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();
}