On registration I want to get the value of the user's email and forward them to a page that has an option to resend their activation email. I have the page with the form they're forwarded to, but I need some place to add the user's email address to a $session variable when user_register is being submitted. Apparently there is no submit_hook for that form without overriding it entirely (which I would rather not do).

This is the code I have so far:

function mymodule_form_alter(&$form, &$form_state, $form_id){
    global $user;

    if($form_id=='user_register_form' && $user->uid != 1 && !in_array('manager', array_values($user->roles)))
        $form['actions']['submit']['#value'] = 'Create Account';
        $form['account']['mail']['#description'] = "Please use a valid email address as you will need to verify it.";
        $form['account']['mail']['#attributes'] = array('placeholder' => '[email protected]');
        $form['account']['mail']['#title'] = 'Email Address';
        $form['account']['name']['#description'] = "";

        $form['#action'] .= '?destination=node/'.variable_get('checkemailpage', 6);

  • If the answer helped you, you should accept it. If not, there may need to be some clarification. Commented Jul 24, 2013 at 1:23

1 Answer 1


You can add additional submit callback function to the registration form, then assign user's email to a session so you can call it on the destination page.

Add the following line after $form['#action']

$form['#submit'][] = 'custom_user_register_submit';

Then add this function to your custom module

function custom_user_register_submit(&$form, &$form_state) {

  $_SESSION['custom_user_mail'] = $form_state['values']['mail'];  

Then call $_SESSION['custom_user_mail'] on any page you want.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.