You are here

function _bakery_register_submit in Bakery Single Sign-On System 7.3

Same name and namespace in other branches
  1. 8.2 bakery.module \_bakery_register_submit()
  2. 6.2 bakery.module \_bakery_register_submit()
  3. 7.2 bakery.module \_bakery_register_submit()

Handle registration by redirecting to master.

1 string reference to '_bakery_register_submit'
bakery_form_alter in ./bakery.module
Implements hook_form_alter().

File

./bakery.module, line 334

Code

function _bakery_register_submit($form, &$form_state) {
  global $base_url;

  // Create an array of fields to send to the master. We need these four fields.
  $allowed = array(
    'name',
    'mail',
    'pass',
    'timezone',
  );
  foreach ($form_state['values'] as $key => $value) {
    if (!in_array($key, $allowed)) {
      unset($form_state['values'][$key]);
    }
  }

  // Remove unneeded values.
  form_state_values_clean($form_state);

  // Save values to cookie.
  $data = $form_state['values'];
  _bakery_save_destination_param($form, $data);
  unset($_GET['destination']);

  // Store name and email in case of error and return from master.
  $_SESSION['bakery']['register'] = array(
    'name' => $data['name'],
    'mail' => $data['mail'],
  );

  // Create cookie and redirect to master.
  $bakery = bakery_get_bakery();
  $bakery
    ->setSubCookie($data['name'], $data, $base_url . '/');
  drupal_goto(variable_get('bakery_master', 'http://drupal.org/') . 'bakery/register');
}