Registering an incomplete user

Registering incomplete users without a Person attached

You can use the UserManager to register a new incomplete User without a Person attached. Incomplete users have only an email address, role and user group membership assigned to them.

<?php

/** @var \Jadu\Quantum\ServiceApiClient\Manager\UserManager $userManager */
$userManager = $container->get('quantum_service_api_client.manager.user');
$registerForm = $userManager->getIncompleteUserForm();

$createdIncompleteUser = $userManager->registerIncompleteUser($registerForm, [
    'email' => 'fred@incomplete.com',
    'privilege_level_name' => 'citizens',
    'user_group_id' => 122
]);

This will give you a User object, containing information such as:

  • email address
  • name
  • role
  • user group membership

Registering incomplete users with a Person attached

You can use the UserManager to register a new incomplete User with a Person attached. Incomplete users have only an email address, role and user group membership assigned to them. If an existing Person can be found that has a matching forename, surname and address, they will be linked to the new incomplete user. If a matching Person is found that already has a user assigned though, they will be ignored and a new Person created. Similarly, a new Person will be created if no matching one can be found.

<?php

/** @var \Jadu\Quantum\ServiceApiClient\Manager\UserManager $userManager */
$userManager = $container->get('quantum_service_api_client.manager.user');
$registerForm = $userManager->getIncompleteUserWithPersonForm();

$createdIncompleteUser = $userManager->registerIncompleteUserWithPerson($registerForm, [
    'address_reference' => 'Pz123123',
    'email' => 'fred@incomplete.com',
    'forename' => 'Fred',
    'middle_names' => 'Harry',
    'telephone_primary' => '01234567890',
    'privilege_level_name' => 'citizens',
    'telephone_secondary' => '02341234567',
    'surname' => 'Johnson',
    'title' => 'Mr',
    'user_group_id' => 122
]);

This will give you a User object, containing information such as:

  • email address
  • name
  • role
  • user group membership

The Person associated with the user may be fetched and inspected like this:

<?php

$person = $createdIncompleteUser->getPerson();
print 'Full name: ' . $person->getFullName() . PHP_EOL;
print 'Telephone: ' . $person->getTelephonePrimary() . PHP_EOL;
print 'Address: ' . $person->getAddress()->getSummary() . PHP_EOL;

results matching ""

    No results matching ""