PHP code example of automattic / jetpack-roles

1. Go to this page and download the library: Download automattic/jetpack-roles library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

automattic / jetpack-roles example snippets


use Automattic\Jetpack\Roles;

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

use Automattic\Jetpack\Roles;

$roles = new Roles();
$user  = get_user_by( '[email protected]' );
$user_role = $roles->translate_user_to_role( $user );

use Automattic\Jetpack\Roles;

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