Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save GitYili/11164163 to your computer and use it in GitHub Desktop.
Save GitYili/11164163 to your computer and use it in GitHub Desktop.
<?php
/**
* Implements hook_preprocess_HOOK().
*
*/
function MYTHEME_preprocess_html(&$vars) {
// Fixes page titles for login, register & password.
switch (current_path()) {
case 'user':
$vars['head_title_array']['title'] = t('Login');
$head_title = $vars['head_title_array'];
$vars['head_title'] = implode(' | ', $head_title);
break;
case 'user/register':
$vars['head_title_array']['title'] = t('Create new account');
$head_title = $vars['head_title_array'];
$vars['head_title'] = implode(' | ', $head_title);
break;
case 'user/password':
$vars['head_title_array']['title'] = t('Request new password');
$head_title = $vars['head_title_array'];
$vars['head_title'] = implode(' | ', $head_title);
break;
default:
break;
}
}
/**
* Implements hook_preprocess_HOOK().
*
*/
function MYTHEME_preprocess_page(&$vars) {
/**
* Removes the tabs from user login, register & password. Also fixes page titles
*/
switch (current_path()) {
case 'user':
$vars['title'] = t('Login');
unset($vars['tabs']['#primary']);
break;
case 'user/register':
$vars['title'] = t('Create new account');
unset($vars['tabs']['#primary']);
break;
case 'user/password':
$vars['title'] = t('Request new password');
unset($vars['tabs']['#primary']);
break;
default:
break;
}
}
/**
* Implements hook_form_FORM_ID_alter()
*
**/
function MYTHEME_form_user_login_alter(&$form, &$form_state, $form_id) {
$actions_suffix = '<div class="actions-suffix">';
$actions_suffix .= l(t('Request new password'), 'user/password', array('attributes' => array('class' => 'btn-login-password', 'title' => t('Get a new password'))));
if (user_register_access()):
$actions_suffix .= l(t('Create new account'), 'user/register', array('attributes' => array('class' => 'btn-login-register', 'title' => t('Create a new user account'))));
endif;
$actions_suffix .= '</div>';
$form['actions']['#suffix'] = $actions_suffix;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment