Skip to content

Custom moderators and admins

Frug edited this page Oct 11, 2012 · 1 revision

How to grant admin/moderator rights to a specific user

If you're using the standalone version you can directly edit admin/moderator rights.
The forum integration versions of AJAX Chat take over the forum's privilege system:

  • Forum admins become chat admins
  • Global forum moderators become chat moderators
To grant other users admin/moderator rights you have to adjust the method getValidLoginUserData() in lib/class/CustomAJAXChat.php:
To grant moderator rights to a specific user with the userID 123456 you could add
if($userData['userID'] == 123456)
   $userData['userRole'] = AJAX_CHAT_MODERATOR;
before
return $userData;

You could also add a list of additional moderators as a custom configuration option:
Edit lib/config.php and add

// Defines an array of userIDs (e.g. array(0, 1)) which will be granted moderator privileges (will be ignored if set to null):
$config['customModeratorList'] = array(123,456,789);
before
?>
Then adjust the method getValidLoginUserData() in lib/class/CustomAJAXChat.php:
Add
if($this->getConfig('customModeratorList') && in_array($userData['userID'], $this->getConfig('customModeratorList'))) {
   $userData['userRole'] = AJAX_CHAT_MODERATOR;
}
before
return $userData;

Note 1 - Admin rights:
To grant admin rights instead of moderator rights, use AJAX_CHAT_ADMIN instead of AJAX_CHAT_MODERATOR.

Note 2 - How to retrieve the userID for a given userName:
How to retrieve the userID for a given userName depends on the forum/community system that is used with AJAX Chat. Most systems have the userID in the link to the user's profile - e.g. a phpBB3 link to a user profile looks like this:
https://blueimp.net/forum/memberlist.php?mode=viewprofile&u=3
This is the profile link for the user madblueimp - the userID of madblueimp is the number at the end - 3.