Hello Community,
I am trying to make e PHP function that will run when a hook is triggered.
The function must add a user to a user-group.
This is what i have so far
PHP Code:
$userId = $arrData["member_id"];
$groupId = "3";
$groups = $this->Database->prepare('SELECT groups FROM tl_member WHERE id=?')->execute($userId)->next()->groups;
$groups = unserialize($groups);
array_push($groups, $groupId);
$groups = serialize($groups);
$this->Database->prepare('UPDATE tl_member %s WHERE id=?')->set(array('groups' => $groups))->execute($userId);
This will update the user-group,
But do i need to add an entry to "tl_member_to_group" because there is no entry and when i add someone to a user-group in the backend it will add it also to "tl_member_to_group"
Bookmarks