Creating custom user registration form in Drupal 7

Creating custom user registration form sometimes can be a little tricky, but lets try to create a custom registration form in Drupal 7 with just a few steps.

First we add a few lines of codes to template.php as follows

function themename_theme($existing, $type, $theme, $path){
    'render element'=>'form',
    'template' =>'templates/user-register',
return $hooks;

function themename_preprocess_user_register(&$variables) {
  $variables['form'] = drupal_build_form('user_register_form', user_register_form(array()));

Then creating the user-register.tpl.php and place it inside templates folder in your theme, write the following in your user-register.tpl.php:

  print render($form['form_id']);
  print render($form['form_build_id']);
  print render($form['account']['name']);
  print render($form['account']['mail']);
  print render($form['field_yourcustomfield']); // Your Drupal 7 profile field if any.
  print drupal_render($form['actions']); 

Clear your Drupal cache and visit your user registration form to see the changes.

Send data and read JSON string from URL (HTTP Request)

Some time ago I need to creating a Webform where visitors need to fill in the data required before they can download a specific file.

So the order is as follows:

  1. Send data to the server such as name, email, company, etc. (site A and site B has different server).
  2. Read the string given by the server in the form of JSON. The given string is a place where we can download the file.

Examples of JSON string:


As usual, I use Drupal, and using the Webform module.

To be much faster, I just changed the webform-confirmation.tpl.php and named according to the ID of the webform (eg webform-confirmation-1.tpl.php) and put it in the theme folder that is used. Here is the code:

$submission_data = webform_menu_submission_load($sid, $node->nid);
 $url = '';
 $data = array (
  'manager' => $submission_data->data[1]['value'][0],
  'email' => $submission_data->data[2]['value'][0],
  'company' => $submission_data->data[3]['value'][0],
  'country' => $submission_data->data[4]['value'][0],
  'model' => $submission_data->data[5]['value'][0],
  'feature' => $submission_data->data[6]['value'][0],
  'srlnbr' => $submission_data->data[7]['value'][0],
  'prodid' => $submission_data->data[8]['value'][0]
 $query = http_build_query($data, '', '&');
 $f_url = $url . $query;
 $content = file_get_contents($f_url);
 $json = json_decode($content);
 $dl = $json->{'downloadUrl'};
 if ($dl == '') {
  // null
 else {
  header('Refresh: 3; URL=' . $dl);

With the solution above, we do not need to use JavaScript / jQuery. We could also use drupal_http_request(); but more effective using above methods because I need to read the JSON string also.

SEOzoic: The Web and Business Directory

After several months of trying to find the right format for one of my projects I finally officially released a new service that is web and business directory named SEOzoic.

This is paid directory with an annual recurring charge, my expectations with that model it can minimizing the spam and to maintain the quality of the listing itself.

Currently there are already several companies, organizations and individuals listed there. Visit the directory here.