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.
3 Answers
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.
-
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– whyCommented 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
-
-
1Then 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– whyCommented Jan 22, 2013 at 9:31
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.
-
-
hi again..i have added the formblock-user register in the panel but its not showing up..even in preview...why so?– whyCommented Jan 22, 2013 at 9:19
-
-
-
@Nikhil..thanks a lot..i had done that but the changes were not reflecting...i cleared the cache once..now its there..thank you– whyCommented Jan 22, 2013 at 9:22
It is pretty simple to handle this. I fixed this on Drupal 7 like below
Create block say 'User register form' in content top.
Put this code in its body
<?php print drupal_render(drupal_get_form('user_register_form')); ?>
In text format select PHP code
In visibility settings, under roles select 'Anonymous user' or who ever who wants to see the form.
-
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