Implements hook_block_view_MODULE_DELTA_alter().
Adds the OpenID login form to the user login block.
user_login_block()
function openid_block_view_user_login_alter(&$block) {
// Only alter the block when it is non-empty, i.e. when no user is logged in.
if (!isset($block['content'])) {
return;
}
$block['content']['openid_login_form'] = drupal_get_form('openid_login_form');
$block['content']['openid_login_form']['openid_identifier']['#size'] = $block['content']['user_login_form']['name']['#size'];
// Put an OpenID link as a first element.
$block['content']['user_links']['#items'] = array(
l(t('Log in using OpenID'), 'user/login/openid', array(
'attributes' => array(
'title' => t('Log in using OpenID.'),
'class' => array(
'openid-link',
),
'role' => 'button',
'tabindex' => 0,
),
)),
) + $block['content']['user_links']['#items'];
// Move links under the openid form.
$block['content']['user_links']['#weight'] = 10;
}