I have an user register form alter on my template.php and this is the code:
function mymodule_theme(&$ existing, $ type, $ theme, $ path){ $ hooks = array(); $ hooks['user_register_form'] = array( 'render element'=>'form', 'title' => 'Registro de candidatas', 'template' =>'templates/user-register', ); return $ hooks; } function mymodule_form_user_register_form_alter(&$ form, &$ form_state, $ form_id) { $ form['mail'] = array( '#type' => 'textfield', '#title_display' => 'invisible', '#attributes' => array( 'placeholder' => t('Escribe tu correo electrónico'), 'class' => array( 'mymodule-form-email-input' ) ), '#required' => true ); $ form['pass'] = array( '#type' => 'password', '#title_display' => 'invisible', '#attributes' => array( 'placeholder' => t('Escribe tu contraseña'), 'class' => array( 'mymodule-form-email-input' ) ), '#required' => true ); $ form['captcha'] = array( '#type' => 'captcha', '#captcha_type' => 'recaptcha/reCAPTCHA', '#attributes' => array('class' => 'captcha') ); $ form['submit'] = array( '#type' => 'submit', '#value' => t('Regístrate ahora') ); $ form['#validate'][] = 'mymodule_form_user_register_form_validate'; $ form['#submit'][] = 'mymodule_form_user_register_form_submit'; return $ form; } function mymodule_form_user_register_form_validate($ form, &$ form_state) { var_dump($ form_state); echo 'This is my function'; drupal_set_message(t('AN ERROR OCURED')); if (empty($ form_state['values']['mail'])) { form_set_error('mail', t('Escribe un correo electrónico')); } else { if(valid_email_address($ form_state['values']['mail'])) { form_set_error('mail', t('Email invalido')); } } if (empty($ form_state['values']['pass'])) { form_set_error('pass', t('Escribe una contraseña')); } /* if (!$ form_state['values']['sendgift']) { form_set_error(NULL, '', TRUE); drupal_get_messages(); } */ } function mymodule_form_user_register_form_submit($ form, &$ form_state) { echo ('This is my custom message'); /* $ newuser = array( 'pass' => $ form_state['values']['pass']['pass2'], 'mail' => $ form_state['values']['mail'], 'init' => $ form_state['values']['mail'], 'status' => 1, ); $ user = user_save('', $ newuser); $ user->password = $ pass; // Add plain text password into user account to generate mail tokens. _user_mail_notify('register_no_approval_required', $ user); drupal_set_message('Tu registro ha sido procesado, ahora ve a tu email y activalo!'); */ }
And I have the callbacks mymodule_form_user_register_form_validate
and mymodule_form_user_register_form_submit
inside mymodule_form_user_register_form_alter
but these functions aren’t called when I submit the form. Something wrong here? Please help. Thanks!