6

I want the user registration to appear in a block in some other page than home, let's say a page called "Sign up." What I want to achieve is the following.

screenshot

2
  • you should check out the logintoboggon module Commented Jan 22, 2013 at 7:17
  • hi...thanks for reply..i tried that..but it simple redirects to the normal registration page...
    – why
    Commented Jan 22, 2013 at 7:19

3 Answers 3

0

To achieve according to your use case you have to render login form on node or on page, if i am not wrong.

You can add following snippet to render the login form.

The user_block_view() function has this line in it for the login delta:

if (!$user->uid && !(arg(0) == 'user' && !is_numeric(arg(1)))) {

If you're logged in, the function will return an empty array, which is probably what's happening in your case.

If that's not the reason (and even if it is) you can get around it by calling the form function directly:

print drupal_render(drupal_get_form('user_login_block'));

There doesn't appear to be any extra access checks done in the form function so it should be rendered regardless of whether you're logged in or not.

7
  • hi..m quite new at drupal..can u tell me which file do i have to edit and where can i find them...i am using a zen starter theme
    – why
    Commented Jan 22, 2013 at 7:34
  • but as shown in your use case there is image for login, can you briefly explain me where exactly do you want to integrate this form in your drupal site Commented Jan 22, 2013 at 7:45
  • i want to integrate it in a new page
    – why
    Commented Jan 22, 2013 at 8:25
  • 1
    Then you have to add this code in page.tpl.php file..but if you have understanding of panel then you can try the solution given by @Nikhil N Commented Jan 22, 2013 at 8:46
  • 1
    @nikhil...its works...after clearing the cache though..thanks a ton
    – why
    Commented Jan 22, 2013 at 9:31
11

Well there is Form Block

Enables the presentation of user registration, site wide contact, or node creation forms in blocks. This is particularly useful for including forms on panels.

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

enter image description here

7
  • hi..how do i enable it for user registration block
    – why
    Commented Jan 22, 2013 at 9:08
  • hi again..i have added the formblock-user register in the panel but its not showing up..even in preview...why so?
    – why
    Commented Jan 22, 2013 at 9:19
  • @kewal See my edit
    – niksmac
    Commented Jan 22, 2013 at 9:19
  • To see the regn form you should be logged out.
    – niksmac
    Commented Jan 22, 2013 at 9:21
  • @Nikhil..thanks a lot..i had done that but the changes were not reflecting...i cleared the cache once..now its there..thank you
    – why
    Commented Jan 22, 2013 at 9:22
-1

It is pretty simple to handle this. I fixed this on Drupal 7 like below

  1. Create block say 'User register form' in content top.

  2. Put this code in its body <?php print drupal_render(drupal_get_form('user_register_form')); ?>

  3. In text format select PHP code

  4. In visibility settings, under roles select 'Anonymous user' or who ever who wants to see the form.

1
  • One addition: You also require Drupal core's php module in order to see the PHP text format. Commented May 25, 2016 at 22:08

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.