Display a Drupal login form anywhere with PHP, including in page content

Key words and phrases: 
show Drupal user login form display user registration form in page signup form custom placement
Description & Info: 

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

user_login_block

Tim Yager:

i found that to correctly display the user login block you use
print drupal_get_form('user_login_block');

Posted by Benjamin Melançon on Sat, 2008-03-15 19:58
Post new comment
The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <blockquote> <h1> <h2> <h3> <h4> <h5> <h6> <small> <pre> <strike> <sub> <sup>
  • Lines and paragraphs break automatically.
  • Web page addresses and e-mail addresses turn into links automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Copy the characters (respecting upper/lower case) from the image.