function profile2_form_after_user_register_submit_handler in Profile 2 7
Same name and namespace in other branches
- 7.2 profile2.module \profile2_form_after_user_register_submit_handler()
User registration form submit handler that executes right after user_register_submit().
This callback sends delayed email notification to a user about his registration. See https://drupal.org/node/1097684.
See also
profile2_form_prepare_user_register_submit_handler()
1 string reference to 'profile2_form_after_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 631 - Support for configurable user profiles.
Code
function profile2_form_after_user_register_submit_handler(&$form, &$form_state) {
global $conf;
// List of registration operations that where
// notification values were changed.
$changed_ops =& drupal_static('profile2_register_changed_operations', array());
// List of available operations during the registration.
$register_ops = array(
'register_admin_created',
'register_no_approval_required',
'register_pending_approval',
);
foreach ($register_ops as $op) {
// If we changed the notification value in
// profile2_form_before_user_register_submit_handler() then change it back.
if (isset($changed_ops['user_mail_' . $op . '_notify'])) {
$conf['user_mail_' . $op . '_notify'] = $changed_ops['user_mail_' . $op . '_notify'];
}
else {
unset($conf['user_mail_' . $op . '_notify']);
}
}
// Get the values that we need to define which notification
// should be sent to the user. Generally this is a trimmed version
// of user_register_submit() callback.
$admin = !empty($form_state['values']['administer_users']);
$account = $form_state['user'];
$notify = !empty($form_state['values']['notify']);
if ($admin && !$notify) {
// If admin has created a new account and decided to don't notify a user -
// then just do nothing.
}
elseif (!$admin && !variable_get('user_email_verification', TRUE) && $account->status) {
_user_mail_notify('register_no_approval_required', $account);
}
elseif ($account->status || $notify) {
$op = $notify ? 'register_admin_created' : 'register_no_approval_required';
_user_mail_notify($op, $account);
}
elseif (!$admin) {
_user_mail_notify('register_pending_approval', $account);
}
}