You may need to change the current logged in user group information after a content submission.

Let's say the user has filled a survey and you want to grant them access on the website to extra content as rewards. And of course you want to do this without having to force the user to logout/login for the changes to take effect.

Here are some useful Joomla functions you can implement in an 'AfterStore' plugin ( You can find it here)

To get the current user logged in user php object :

$user = JFactory::getUser();

or if you need extra information from the user stored in SEBLOD tables :

$user = JCck::getUser();

You may also want your code to only be executed when a content is created and not updated. In this case you have to put your code in a 'if' :

if ( $config['isNew'] ) {

Add a group to a user

$groupId = 5; //Default Joomla Publisher group id
JUserHelper::addUserToGroup( $user->id, $groupId );

Set the groups for a user

This will replace the current user groups by the ones you pass to the function

$groups = array( 5, 6 );
JUserHelper::setUserGroups( $user->id, $groups );

Remove a user from a group

$groupId = 5; //Default Joomla Publisher group id
JUserHelper::removeUserFromGroup( $user->id, $groupId );

If you want to check your group update is in place, you can use this function to retrieve user groups

$userGroups = JUserHelper::getUserGroups( $user->id );