Custom user login block

TAGS:

We never had a reason to know how easy it is to add a login block until recently. Sure, we enable the default User login block and tell it to appear wherever, but what if you want the title to appear differently depending on the path?

Simple, create a new block that uses PHP input format and stuff this into the body:

<?php if (!user_is_logged_in()): ?>
<?php print drupal_get_form('user_login'); ?>
<?php endif; ?>

Set the title of the block as desired. Save the block and move it into any region, telling it to display on a specific path.

You could also set the page title based on the path or tokens and call:

drupal_set_title()

Both API calls can be referenced here:
drupal_get_form()
drupal_set_title()

Comments

  • Showing 1-0 of 0

Post new comment

Image CAPTCHA
Enter the characters shown in the image.