array( 'message' => 'User creation failed for '.$username ))); exit(); } foreach( $groups as $i ) { if(!OC_Group::groupExists($i)) { OC_Group::createGroup($i); } OC_Group::addToGroup( $username, $i ); } OC_JSON::success(array("data" => array( "username" => $username, "groups" => OC_Group::getUserGroups( $username )))); } catch (Exception $exception) { OC_JSON::error(array("data" => array( "message" => $exception->getMessage()))); }