Search code examples
formsauthenticationdrupal-7

Drupal render login form programmatically


I'm trying to display the login form in a basic page. When I'm logged in, this redirects me to the user account page. When I'm logged out, this shows nothing.

<?php drupal_get_form("user_login"); ?>

Solution

  • Solved!

    For D7:

    <?php 
    $elements = drupal_get_form("user_login"); 
    $form = drupal_render($elements);
    echo $form;
    ?>
    

    For D6:

    <?php 
    echo drupal_get_form("user_login");
    ?>