Last updated September 9, 2012. Created by carwin on September 9, 2012.
Log in to edit this page.

Firstly, in your theme's root directory add the following to template.php. If the file does not exist, create it.

function YOURTHEME_theme(&$existing, $type, $theme, $path){
$hooks = array();
// Make user-register.tpl.php available
$hooks['user_register_form'] = array (
'render element' => 'form',
'path' => drupal_get_path('theme','YOURTHEME'),
'template' => 'user-register',
'preprocess functions' => array('YOURTHEME_preprocess_user_register_form'),
YOURTHEME_preprocess_user_register_form(&$vars) {
$args = func_get_args();
$form_state['build_info']['args'] = $args;
$vars['form'] = drupal_build_form('user_register_form', $form_state['build_info']['args']);

Account fields

Account fields are rendered following the pattern of the two required fields, 'name' and 'mail':

print render($form['account']['name']);

Profile2 Support

To load Profile2 fields into the user registration form manually, use this pattern:

print render($form['profile_theprofile_name']['field_thefield_name']);

Also, I make use of field group module (here) with Profile2 and noticed that I didn't need to include anything about the field group a Profile2 field is in to render that field.


If you use the CAPTCHA module and need to build your own user-register.tpl.php you'll need this to render it:

print render($form['captcha']);

This took me longer than it should of to figure it out.


Lastly, if you want your form to actually be usable, the following snippet is required to build the form action stuff:

print drupal_render($form['actions']);

This page is a reference page spawned from this support thread in the Theme Development forum.

Looking for support? Visit the forums, or join #drupal-support in IRC.


Note: Regarding profile2 form elements and in order for them to be available, you have to tick the checkbox Show during user account registration. under your profile type. Otherwise the $form['profile_name'] won't be available.

But if check 'Show during user account registration' then the whole Profile2 is shown... so all the fields. And that's not what we want. :S

Drupal Association individual member