Skip to content

Latest commit

 

History

History
 
 

Roles

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

You have to be logged in and have relevant permissions.

ROLES LISTING

$listing = \ATDev\RocketChat\Roles\Role::listing();

if (!$listing) {

	// Log the error
	$error = \ATDev\RocketChat\Roles\Role::getError();
}

ROLE SYNC

$result = \ATDev\RocketChat\Roles\Role::sync("2021-04-19T15:08:17.248Z");

if (!$result) {
	// Log the error
	$error = \ATDev\RocketChat\Roles\Role::getError();
}

CREATE ROLE

$role = new \ATDev\RocketChat\Roles\Role();
$role->setName("[ROLE NAME]");
$role->setScope("[ROLE SCOPE]");
$role->setDescription("[ROLE DESCRIPTION]");

$result = $role->create();

if (!$result) {
	// Log the error
	$error = $role->getError();
}

ASSIGN A ROLE TO AN USER

$role = (new \ATDev\RocketChat\Roles\Role())->setName("[ROLE NAME]");

$result = $role->addUserToRole("[USERNAME]", "[ROOM ID]");

if (!$result) {
	// Log the error
	$error = $role->getError();
}

GETS THE USERS THAT BELONGS TO A ROLE

$role = (new \ATDev\RocketChat\Roles\Role())->setName("[ROLE NAME]");

$result = $role->getUsersInRole(5, 10, "[ROOM ID]");

if (!$result) {
	// Log the error
	$error = $role->getError();
}