translate_level_to_role() WordPress Function

This function translates a given user level to a corresponding role. User levels are integers, with 0 being the lowest and 10 being the highest. Roles are strings, and are used to indicate the permissions and capabilities a user has.

translate_level_to_role( int $level ) #

Translate user level to user role name.


Parameters

$level

(int)(Required)User level.


Top ↑

Return

(string) User role name.


Top ↑

Source

File: wp-admin/includes/upgrade.php

function translate_level_to_role( $level ) {
	switch ( $level ) {
		case 10:
		case 9:
		case 8:
			return 'administrator';
		case 7:
		case 6:
		case 5:
			return 'editor';
		case 4:
		case 3:
		case 2:
			return 'author';
		case 1:
			return 'contributor';
		case 0:
		default:
			return 'subscriber';
	}
}

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.