Warning: This method has been deprecated. Use WP_User::for_site() instead.

WP_User::_init_caps() WordPress Method

The WP_User::_init_caps() method is used to initialize the user's capabilities when they first log in. This is done by reading the user's meta data and mapping it to the capabilities defined in the WordPress codebase.

WP_User::_init_caps( string $cap_key = '' ) #

Sets up capability object properties.


Description

Will set the value for the ‘cap_key’ property to current database table prefix, followed by ‘capabilities’. Will then check to see if the property matching the ‘cap_key’ exists and is an array. If so, it will be used.


Top ↑

Parameters

$cap_key

(string)(Optional)capability key

Default value: ''


Top ↑

Source

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

	protected function _init_caps( $cap_key = '' ) {
		global $wpdb;

		_deprecated_function( __METHOD__, '4.9.0', 'WP_User::for_site()' );

		if ( empty( $cap_key ) ) {
			$this->cap_key = $wpdb->get_blog_prefix( $this->site_id ) . 'capabilities';
		} else {
			$this->cap_key = $cap_key;
		}

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

		$this->get_role_caps();
	}


Top ↑

Changelog

Changelog
VersionDescription
4.9.0Use WP_User::for_site()
2.1.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.