Redirect after registration. Show your page after user's registration

Drupal: 

Drupal message like "Check your mail.." on the home page - this is not the best way to inform the user that he has successfully registered and has to check e-mail.
Next hook shows the node number 76 after the registration, but do not show if administrator or editor create new account.
If you have a multilingual site and the material translated into languages, Drupal automatically selects the language translation for the current user's language (the language test is not needed, supported by Drupal).

  1. /*redirect after user register to page check your mail message*/
  2. function redirect_after_regisration_form_alter(&$form, &$form_state,$form_id) {
  3. global $user;
  4. //if current user has roles administrator or editor return
  5. foreach ($user->roles as $role) { if (($role == 'administrator') || ($role == 'editor')) return; }
  6.  
  7. if ($form_id == 'user_register_form')
  8. $form['#submit'][] = 'redirect_after_regisration_user_register_submit';
  9. }
  10.  
  11. function redirect_after_regisration_user_register_submit($form, &$form_state) {
  12. $form_state['redirect'] = 'node/76'; /* CHANGE 76 to your node id with message after registration */
  13. }
Category: