Reputation: 1
i want to change usergroup for user who has paid for subscription. I wrote that code
$user = $modx->getObject('modUser', array('username' => $username));
if( $user ){
$user->save();
$user->joinGroup('5');
}
but it`s still not changing his usergroup, what can be wrong ? Thanks for answer !
Upvotes: 0
Views: 60
Reputation: 2281
You forgot to save user AFTER changing his group. Just try
$user = $modx->getObject('modUser', array('username' => $username));
if( $user ){
$user->joinGroup('5');
$user->save();
}
Upvotes: 1