Skip to content

Instantly share code, notes, and snippets.

@ivandoric
Created April 23, 2014 13:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ivandoric/11215326 to your computer and use it in GitHub Desktop.
Save ivandoric/11215326 to your computer and use it in GitHub Desktop.
drupal: user register form template
<?php
//Add this to template.php
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'),
);
return $hooks;
}
function YOURTHEME_preprocess_user_register_form(&$vars) {
$args = func_get_args();
array_shift($args);
$form_state['build_info']['args'] = $args;
$vars['form'] = drupal_build_form('user_register_form', $form_state['build_info']['args']);
}
//###### render fields in user-register.php like this
print render($form['account']['name']);
print render($form['account']['mail']);
print render ($form['field_firstname']);
print render ($form['field_lastname']);
//Don't forget to add this to make the form usable
print drupal_render($form['actions']);
print drupal_render($form['form_build_id']);
print drupal_render($form['form_id']);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment