WP_Role::has_cap( string $cap )

Determines whether the role has the given capability.


Parameters

$cap

(Required) Capability name.


Return

(bool) Whether the role has the given capability.


Source

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

	public function has_cap( $cap ) {
		/**
		 * Filters which capabilities a role has.
		 *
		 * @since WP-2.0.0
		 *
		 * @param array  $capabilities Array of role capabilities.
		 * @param string $cap          Capability name.
		 * @param string $name         Role name.
		 */
		$capabilities = apply_filters( 'role_has_cap', $this->capabilities, $cap, $this->name );

		if ( !empty( $capabilities[$cap] ) )
			return $capabilities[$cap];
		else
			return false;
	}

Changelog

Changelog
Version Description
2.0.0 Introduced.