set_role

Description

This method assigns a role to a user. The user must be already set before processing this API method.

Usage

<?php UM()->roles()->set_role( $user_id, $role ); ?>

Parameters

$user_id

(integer)(required)  The user id.

$role

(string) (required) The user role slug you want to assign to the user.

Returns

Changes user role if the given user role was a valid plugin role.

Examples

Set a user and give them the role of community-member

//Change user role
UM()->roles()->set_role(112,'community-member'); ?>