WP_Roles::for_site() WordPress Method
The WP_Roles::for_site() method is a static member function of the WP_Roles class. It returns an array of roles and their capabilities for the current site.
WP_Roles::for_site( int $site_id = null ) #
Sets the site to operate on. Defaults to the current site.
Parameters
- $site_id
(int)(Optional)Site ID to initialize roles for. Default is the current site.
Default value: null
Source
File: wp-includes/class-wp-roles.php
public function for_site( $site_id = null ) { global $wpdb; if ( ! empty( $site_id ) ) { $this->site_id = absint( $site_id ); } else { $this->site_id = get_current_blog_id(); } $this->role_key = $wpdb->get_blog_prefix( $this->site_id ) . 'user_roles'; if ( ! empty( $this->roles ) && ! $this->use_db ) { return; } $this->roles = $this->get_roles_data(); $this->init_roles(); }
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
Version | Description |
---|---|
4.9.0 | Introduced. |