You are here

function profile2_form_before_user_register_submit_handler in Profile 2 7

Same name and namespace in other branches
  1. 7.2 profile2.module \profile2_form_before_user_register_submit_handler()

User registration form submit handler that executes right before user_register_submit().

In generally, this callback disables the notification emails during the execution of user_register_submit() callback. The reason for this - we want to support profile2 tokens in emails during registration, and there is no another proper way to do this. See https://drupal.org/node/1097684.

See also

profile2_form_after_user_register_submit_handler()

user_register_submit()

profile2_attach_form()

1 string reference to 'profile2_form_before_user_register_submit_handler'
profile2_attach_form in ./profile2.module
Attaches the profile forms of the profiles set in $form_state['profiles'].

File

./profile2.module, line 599
Support for configurable user profiles.

Code

function profile2_form_before_user_register_submit_handler(&$form, &$form_state) {
  global $conf;

  // List of available operations during the registration.
  $register_ops = array(
    'register_admin_created',
    'register_no_approval_required',
    'register_pending_approval',
  );

  // We also have to track if we change a variables, because
  // later we have to restore them.
  $changed_ops =& drupal_static('profile2_register_changed_operations', array());
  foreach ($register_ops as $op) {

    // Save variable value.
    if (isset($conf['user_mail_' . $op . '_notify'])) {
      $changed_ops['user_mail_' . $op . '_notify'] = $conf['user_mail_' . $op . '_notify'];
    }

    // Temporary disable the notification about registration.
    $conf['user_mail_' . $op . '_notify'] = FALSE;
  }
}