DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Drupal 6: Defaulting To OpenID
Visually enable the OpenID login before the normal login.
Add this to template.php
function garland_theme() {
return array(
'user_login' => array(
'template' => 'user-login',
'arguments' => array('form' => NULL),
),
'user_register' => array(
'template' => 'user-register',
'arguments' => array('form' => NULL),
),
'user_pass' => array(
'template' => 'user-pass',
'arguments' => array('form' => NULL),
),
'user_login_block' => array(
'template' => 'user-login-block',
'arguments' => array('form' => NULL),
),
);
}
Add this to a new file called user-login.tpl.php
<?php
// reverse default form element visibility toggles set in openid module js
drupal_add_js('$(document).ready(function(){var a=$("#edit-name-wrapper, #edit-pass-wrapper, li.openid-link");var b=$("#edit-openid-identifier-wrapper, li.user-link");a.hide();b.css("display","block");$("#edit-name, #edit-pass").removeClass("error");$("div.messages.error").hide();$("#edit-openid-identifier")[0].focus()});', 'inline');
// render login form
print(drupal_render($form));
Add this to a new file called user-login-block.tpl.php
<?php
// reverse default form element visibility toggles set in openid module js
drupal_add_js('$(document).ready(function(){var a=$("#edit-name-wrapper, #edit-pass-wrapper, li.openid-link");var b=$("#edit-openid-identifier-wrapper, li.user-link");a.hide();b.css("display","block");$("#edit-name, #edit-pass").removeClass("error");$("div.messages.error").hide();$("#edit-openid-identifier")[0].focus()});', 'inline');
// render login form
print(drupal_render($form));
Add this to a new file called user-pass.tpl.php
Visit your <a href="http://openid.net/" title="Learn More about OpenID">OpenID</a> provider to recover your password. Then come back to this site and <a href="user" title="Log in to this site">log in</a> with your OpenID.
Add this to a new file called user-register.tpl.php
Establish your <a href="http://openid.net/" title="Learn More about OpenID">OpenID</a> with a provider like <a href="http://myopenid.com/" title="Visit MyOpenID.com">MyOpenId.com</a>. Then come back to this site and <a href="/user" title="Log in to this site">log in</a> with your new OpenID.





