There are many links in websites that talk about this question, but I'm really bewildered how to do it, I've tested many solutions but I failed.

this is my code to add register form into a page

    if(user_is_anonymous()) {  
    $form = drupal_get_form('user_register_form');
    print drupal_render($form);

it is all I know of register form ! it prints all the fields of registered users. I also added other fields like mobile, phone and ... from admin/config/people/accounts/fields.

what is the most straightforward solution to theme the form? text fields and ... ?

2 Answers 2


You can try this one

To implement hook_form_alter() in a module and set the form's #theme property:

    function mymodule_form_user_register_form_alter(&$form, &$form_state, $form_id) {
      $form['#theme'] = 'user_register';

and add this code to template.php

    function mytheme_theme($existing, $type, $theme, $path){
      return array(
        'user_register' => array(
          'render element' => 'form',
          'template' => 'templates/user-register',

function mytheme_preprocess_user_register(&$variables) {
  $variables['rendered'] = drupal_render_children($variables['form']);

Also, create a user-register.tpl.php in


to add the 'markup' for the desired output and

<?php echo $rendered; ?> 

to print the form.

For more information, follow this https://www.drupal.org/node/1211520

Hope, it works.


Open template.php of your theme

function YOURTHEMENAME_theme($existing, $type, $theme, $path) {

 $hooks['form_id_of_form'] = array(
    'template' => 'path_to_tpl_file',
    'arguments' => array('form' => NULL),
  return $hooks;

Also you can try

function hook_form_alter(&$form, &$form_state, $form_id) {
if($form_id == 'form_id_of_form') {
    $form['#theme'] = 'path_to_tpl_file';


Take a look at the #theme key in the Form API Reference. Take a look at the code for theme_form() for the default implementation.

  • Links are not considered as answers here. Please update your answer with details Jul 4, 2014 at 5:35
  • Updated the answer. Aug 8, 2014 at 14:32

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.