Keyword

Change K2 User Group with php

  • doovers
  • doovers's Avatar Topic Author
  • Offline
  • New Member
More
11 years 1 month ago #117034 by doovers
Change K2 User Group with php was created by doovers
How can I assign a different usergroup to the active user with php?

I believe I can get the active user by using the following code:
Log in  or Create an account to join the conversation.

  • Mohamed Abdelaziz
  • Mohamed Abdelaziz's Avatar
  • Offline
  • Platinum Member
  • Joomla Developer
More
11 years 1 month ago #117035 by Mohamed Abdelaziz
Replied by Mohamed Abdelaziz on topic Re: Change K2 User Group with php
Try this code:
$userGroups = array(groupid);
$user->set('groups', $userGroups);

replace groupid with the proper value, you should pass an array because a user can be assigned to multiple groups.

Multiple Extra Fields Groups for K2
AutoMeta for K2
Chained Fields for K2
More K2 Extensions In My Extensions Store

Please Log in or Create an account to join the conversation.