Skip to: site menu |main content

Welcome to my personal site. If You have any question or suggestion please feel free to contact me from contact page.

Advertisements

Contact me to place your Ads Here..

Powered by Drupal, an open source content management system

Syndicate

Syndicate content
 
 

Customizing the drupal user registration form

--updated added code also--
you can define template for your form in template.php

/**
* @desc ex
*/
function inderin_theme() {
      $themes= array(       
             'user_register' => array(
              'template' => 'user-register',
              'arguments' => array('form' => NULL)
            ),
      );
      return $themes;
}

Place above code in your template.php file make sure to replace inderin_theme with yourtheme_theme for function name.

After you have above code in your template.php then create a user-register.tpl.php in your theme folder and simply place code below:-

<div class="user-login-wrap">
    <div class="login-content-inner" style="padding:10px;border:1px dashed green">
            <?php 
            $form
['name']['#title']='Username/Email';    
//you can control variables before rendering one by one.       
           
print drupal_render($form);
           
?>

    </div>
</div>

These snippets allow you to override the default user registration layout using a custom user_register.tpl.php.

If you want to customize the full page layout, click through to the customizing the login, registration and request password full page layout handbook page.

step 1 of 2

In a text editor like notepad.exe, create a file called template.php using the the following snippet. If you already have a template.php file, simply add it to your existing one (remembering to omit the opening and closing PHP tags if you're adding it to an existing template.php file, i.e. <?php and ?).

step 2 of 2

1. In a text editor create a new text file and paste the following snippet into it. Save the file with the filename user_register.tpl.php
2. Edit the style sheet classes and content to suit
3. Upload your edited user_register.tpl.php to your active theme folder

For use with Drupal 4.7.x

<div class="registration_form">
<p>Extra instructions or content can go here, just above the registration form</p>
<?php
    print_r
(form_render($form)); // this displays the login form.
?>

<p>Extra instructions or content can go here, just below the registration form</p>
</div>
For use with Drupal 5.x

<div class="registration_form"><p>Extra instructions or content can go here, just above the registration form</p>
<?php
    print_r
(drupal_render($form)); // this displays the login form.
?>

Extra instructions or content can go here, just below the registration form

Style sheet reference

For controlling how your registration form looks using your style sheet, this is what the rendered registration form HTML and class names are by default:

<form action="/user/register"  method="post" id="user-register">
<div class="form-item">
<label for="edit-name">Username: <span class="form-required" title="This field is required.">*</span></label>
<input type="text" maxlength="60" name="name" id="edit-name"  size="60" value="" class="form-text required" />
<div class="description">Your preferred username; punctuation is not allowed except for periods, hyphens, and underscores.</div>
</div>
<div class="form-item">
<label for="edit-mail">E-mail address: <span class="form-required" title="This field is required.">*</span></label>
<input type="text" maxlength="64" name="mail" id="edit-mail"  size="60" value="" class="form-text required" />
<div class="description">A valid e-mail address. All e-mails from the system will be sent to this address. The e-mail address is not made public and will only be used if you wish to receive a new password or wish to receive certain news or notifications by e-mail.</div>
</div>
<input type="hidden" name="form_id" id="edit-user-register" value="user_register"  />
<input type="submit" name="op" id="edit-submit" value="Create new account"  class="form-submit" />
----------

 

Where is the code snippet ?

dude, please provide the code snippet and mention under which folder it has to be kept. It is just mis-leading and not giving a clear idea. I am sure you have tried to explain it better, but please put some more details so that it will be easy for newbies to understand.

Good Luck !!

 
 

you can see the updated code

I have added new code..

 

Back to top

Related Pictures

Tags for Customizing the drupal user registration form

Recent comments

InderSingh.com v1.2
(Feb 05, 2012)