oont-contents/plugins/jetpack-boost/jetpack_vendor/automattic/jetpack-roles
2025-04-06 08:34:48 +02:00
..
src Themes & Plugins 2025-02-08 15:10:23 +01:00
CHANGELOG.md origin push 2025-04-06 08:34:48 +02:00
composer.json origin push 2025-04-06 08:34:48 +02:00
LICENSE.txt Themes & Plugins 2025-02-08 15:10:23 +01:00
README.md Themes & Plugins 2025-02-08 15:10:23 +01:00
SECURITY.md Themes & Plugins 2025-02-08 15:10:23 +01:00

Jetpack Roles

A user roles class for Jetpack.

Contains utilities for translating user roles to capabilities and vice versa.

Usage

Get the role of the current user:

use Automattic\Jetpack\Roles;

$roles = new Roles();
$current_user_role = $roles->translate_current_user_to_role();

Get the role of a particular user:

use Automattic\Jetpack\Roles;

$roles = new Roles();
$user  = get_user_by( 'contact@yourjetpack.blog' );
$user_role = $roles->translate_user_to_role( $user );

Get the capability we require for a role:

use Automattic\Jetpack\Roles;

$roles = new Roles();
$capability = $roles->translate_role_to_cap( 'administrator' );

Using this package in your WordPress plugin

If you plan on using this package in your WordPress plugin, we would recommend that you use Jetpack Autoloader as your autoloader. This will allow for maximum interoperability with other plugins that use this package as well.

Security

Need to report a security vulnerability? Go to https://automattic.com/security/ or directly to our security bug bounty site https://hackerone.com/automattic.

License

jetpack-roles is licensed under GNU General Public License v2 (or later)