WP_User::level_reduction()publicWP 2.0.0

Chooses the maximum level the user has.

Will compare the level from the $item parameter against the $max parameter. If the item is incorrect, then just the $max parameter value will be returned.

Used to get the max level based on the capabilities the user has. This is also based on roles, so if the user is assigned the Administrator role then the capability 'level_10' will exist and the user will get that value.

Метод класса: WP_User{}

Хуков нет.


int. Max Level.


$WP_User = new WP_User();
$WP_User->level_reduction( $max, $item );
$max(int) (обязательный)
Max level of user.
$item(строка) (обязательный)
Level capability name.

Список изменений

С версии 2.0.0 Введена.

Код WP_User::level_reduction() WP 6.5.5

public function level_reduction( $max, $item ) {
	if ( preg_match( '/^level_(10|[0-9])$/i', $item, $matches ) ) {
		$level = (int) $matches[1];
		return max( $max, $level );
	} else {
		return $max;