WP_User::update_user_level_from_caps() WordPress Method

The WP_User::update_user_level_from_caps() function is used to update a user's level based on their capabilities. This is useful for sites that use the user_level system for managing user permissions.

WP_User::update_user_level_from_caps() #

Updates the maximum user level for the user.


Description

Updates the ‘user_level’ user metadata (includes prefix that is the database table prefix) with the maximum user level. Gets the value from the all of the capabilities that the user has.


Top ↑

Source

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

	public function update_user_level_from_caps() {
		global $wpdb;
		$this->user_level = array_reduce( array_keys( $this->allcaps ), array( $this, 'level_reduction' ), 0 );
		update_user_meta( $this->ID, $wpdb->get_blog_prefix() . 'user_level', $this->user_level );
	}


Top ↑

Changelog

Changelog
VersionDescription
2.0.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.