1

I would like to modify the look of a user registration page that I am creating. It contains content profile fields and a recaptcha area. I have created a user-register.tpl.php file and updated my template.php file so that this template file is recognized.

I would like to pull out the pieces of the registration form and place them with specific divs for styling. The problem I am having is that I cannot get the fields. I have tried using

print drupal_render(drupal_get_form('user_register'));

but that creates a white page. When I try to just print drupal_get_form('user_register') I get nothing as well. So I am stumped as to what I am doing wrong. It would appear that the drupal_render command is not returning anything so I can't figure out why that would be.

Here is my modification to my template theme:

function mytheme_theme($existing, $type, $theme, $path) {
  return array('user_login'=>array(
    'template'=>'user-login', 
    'arguments'=>array(
        'form'=>NULL),
    ),
    'user_pass'=>array(
        'template'=>'user-pass',
        'arguments'=>array(
            'form'=>NULL), 
    ),
    'user_register'=>array(
         'template'=>'user-register', 
         'arguments'=>array(
            'form'=>NULL), 
    ),   
  ); 
}

This would seem it should work but it doesn't. It is almost like that form does not exist.

I am using Drupal 6.26. Any help would be appreciated!

Thanks

1 Answer 1

0

I found what was causing the problem with not being able to display form elements as described above. The issue was this line in my templates file:

function mytheme_preprocess_user_register(&$variables) {

   $variables['intro_text'] = t('some text.');
   $variables['rendered'] = drupal_render($variables['form']);
}

It looks as though you can only call drupal_render once. Any subsequent calls to drupal_render are ignored as Drupal as already marked the code as rendered. There should be a way to force a re-render if necessary or be able to get the already rendered results. If someone knows how to do this please reply to this post.

The solution was to remove this line from the templates.php file and everything worked.

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.