WP_Roles::get_roles_data() WordPress Method

The WP_Roles::get_roles_data() function is used to get the data for all roles in WordPress. This function returns an array of role data, with each role represented by an array. The role data includes the name, description, and capabilities of the role.

WP_Roles::get_roles_data() #

Gets the available roles data.


Return

(array) Roles array.


Top ↑

Source

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

	protected function get_roles_data() {
		global $wp_user_roles;

		if ( ! empty( $wp_user_roles ) ) {
			return $wp_user_roles;
		}

		if ( is_multisite() && get_current_blog_id() != $this->site_id ) {
			remove_action( 'switch_blog', 'wp_switch_roles_and_user', 1 );

			$roles = get_blog_option( $this->site_id, $this->role_key, array() );

			add_action( 'switch_blog', 'wp_switch_roles_and_user', 1, 2 );

			return $roles;
		}

		return get_option( $this->role_key, array() );
	}


Top ↑

Changelog

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