Home ›
Display a Drupal login form anywhere with PHP, including in page contentDisplay a Drupal login form anywhere with PHP, including in page content
Submitted by Benjamin Melançon on February 28, 2008 - 3:33pm
Update: I gave slightly incorrect code, I'm pretty sure swapping out 'user_register' to put in 'user_login' will work just fine:
dan hak 3:08
whats the code for the login block
benjamin melançon 3:09
<?php
global $user;
if (!$user->uid) {
?>
<div class="user-register">
<?php
print drupal_get_form('user_register');
?>
</div>
<?php
} else {
?>
You are already logged in. GO AWAY!
<?php
}
?>
I'm sending you poetry man
pouring my heart out
a little appreciation please
Resolution
Searched words:
show Drupal user login form
display user registration form in page
signup form custom placement
Comments
user_login_block
Tim Yager:
Thanks
hey!! thanks for the wonderful idea to use drupal's form.
Cheers!!!
user_pass form does not show any fields
I have a sign up link that contains a link for requesting a new password. If i go into admin and clear cached data and then logout and click on the request new password link the form shows correctly in the thickbox i am using. When I refresh the browser and try to click the link a gain the form does not show any fields. I am using Drupal 6. Any help would be appreciated
not working
not working in drupal 6
no form elements displayed
dont know exactly why, but when calling drupal_get_form('user_login_block')
no input fields get displayed (such as username, pass, submit buttom..), but form itself does. Any idea?
its showing 'array' instead
its showing 'array' instead of form. what is the problem
Have to call drupal_render
In response to those who are finding that only the array is printed, you need to pass the array to the drupal_render function. For example:
if(!user_is_logged_in() ){
print drupal_render(drupal_get_form('user_login'));
}else{
print "You are already logged in!";
}
Post new comment