WordPress at a glance
function is not described

WP_User::update_user_level_from_caps() public WP 2.0.0

Update the maximum user level for the user.

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.

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

No Hooks.

Return

````. Null. Nothing.

Usage

$WP_User = new WP_User();
$WP_User->update_user_level_from_caps();

Notes

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

Changelog

Since 2.0.0 Introduced.

Code of WP_User::update_user_level_from_caps() WP 5.7

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