2

I want to override the user registration page, but my code is not working like it used to for Drupal 6.

function mytheme_theme(&$existing, $type, $theme, $path) {
   $hooks['user_login_block'] = array(
     'template' => 'templates/user-login-block',
     'render element' => 'form',
   );
   $hooks['user_login'] = array(
     'template' => 'templates/user-login',
     'render element' => 'form',
   );
   $hooks['user_register'] = array(
     'template' => 'templates/user-register',
     'render element' => 'form',
   );

   return $hooks;
 }

Only the login block hook seems to work.

function mytheme_preprocess_user_login_block(&$vars) {
  $vars['name'] = render($vars['form']['name']);
  $vars['pass'] = render($vars['form']['pass']);
  $vars['submit'] = render($vars['form']['actions']['submit']);
  $vars['rendered'] = drupal_render_children($vars['form']);
}

function mytheme_preprocess_user_register(&$vars) {
  exit;
}

I need this to be a preprocess function so I can change/add variables to put into the template. The second function is never called.

6
  • It should use drupal_render().
    – apaderno
    Aug 1 '11 at 21:20
  • Shouldn't the exit still exit? The login block works.
    – Kevin
    Aug 2 '11 at 2:06
  • If you are using exit to check if the preprocess function to see if it gets called, I would suggest to use watchdog(); the function uses the constant WATCHDOG_DEBUG, which is thought for debugging messages. Using exit in a preprocess function doesn't have any visible effect.
    – apaderno
    Aug 2 '11 at 14:30
  • As side note, the first argument of hook_theme() is not passed by reference.
    – apaderno
    Aug 2 '11 at 14:35
  • Changing it from drupal_render_children to drupal_render causes it to run out of memory. I am using a starterkit from Omega.
    – Kevin
    Aug 2 '11 at 16:51
2

I got it: The theme ID should be user_register_form, not user_register. Now it works.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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