5

I am working on a Drupal project where I require a "Create new account" form on a content page. Can anybody help me out with this? Is there any module or any alternative to get "Create new account" as a block?

4

Use this module http://drupal.org/project/formblock

Download and install the module. Navigate to admin/structure/block You can see Registration form as a block and choose the region to appear.

enter image description here

User Registration to appear in a block taken from this source.

3

You can can create block programmatically. And create your own callback function where you can call drupal_get_form and render user_register_form.

For example your callback function will look like this: Basic example

/**
 * Implements hook_block_info().
 */
function yourmodule_block_info() {
  $blocks = array();
  $blocks['my_block'] = array(
    'info' => t('My Custom Block'),
  );

  return $blocks;
}
function hook_block_view($delta = '') {
    switch ($delta) {
    case 'my_block':
          $block['subject'] = t('Register form');
          $block['content'] = yourmodule_block_register_callback();
     }
}


function yourmodule_block_register_callback() {
   $reg_form = drupal_get_form('user_register_form');
   $output = drupal_render($reg_form);
   return $output;
}

If you are not familiar with the creation of custom modules - read this.

  • Is it not possible through modules or something which is not so programmatic. – user7048 Apr 3 '13 at 13:39
  • it's not as difficult as it seems – Petro Popelyshko Apr 3 '13 at 13:41
2

https://drupal.stackexchange.com/a/21553/23871

Create a new block, copy/paste this code in the body:

<?php

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

?>

Make sure the block is set to PHP filter

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy