set_role

Description

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

Usage

<?php $ultimatemember->user->set_role( $role ); ?>

Parameters

$role

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

Returns

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

Examples

Set a user and give them the role community-member

<?php
// Sets a user. Can accept numeric user ID
um_fetch_user( 14 );
// Change user role
$ultimatemember->user->set_role('community-member');
?>