You are here

function multiple_registration_form_user_register_form_alter in Multiple Registration 8.2

Same name and namespace in other branches
  1. 8 multiple_registration.module \multiple_registration_form_user_register_form_alter()
  2. 7 multiple_registration.module \multiple_registration_form_user_register_form_alter()
  3. 3.x multiple_registration.module \multiple_registration_form_user_register_form_alter()

Implements hook_form_FORM_ID_alter().

File

./multiple_registration.module, line 299
Contains multiple_registration.module.

Code

function multiple_registration_form_user_register_form_alter(&$form, FormStateInterface $form_state, $form_id) {
  $route_match = \Drupal::routeMatch();
  $route = $route_match
    ->getRouteName();
  $current_user = \Drupal::currentUser();
  if ($route === 'multiple_registration.role_registration_page') {

    // Redirect authenticated user to user profile page instead of reg. form.
    if ($current_user
      ->isAuthenticated()) {
      \Drupal::service('multiple_registration.controller_service')
        ->authenticatedUserRedirect($current_user);
    }
    $rid = $route_match
      ->getParameter('rid');

    // Adding role id to the form array.
    $form['rid'] = [
      '#type' => 'value',
      '#value' => $rid,
    ];
    $form['#validate'][] = 'multiple_registration_user_register_form_validate';
  }
}