Tuesday, April 17, 2012

Add Group to User Automatically when Creating a New User with Form

Add this to the form...
public function save($con = null)
  {
    //Do the main save to get an ID
    $user = parent::save($con);
  
    //Add the user to the relevant group, for permissions and authentication
    if (!$user->hasGroup('Dispatchers'))
    {
      $user->addGroupByName('Dispatchers');
      $user->save();
    }
  
    return $user;
  }

No comments:

Post a Comment