Skip to content

Instantly share code, notes, and snippets.

@hachesilva
Created March 3, 2013 01:19
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save hachesilva/5074044 to your computer and use it in GitHub Desktop.
Save hachesilva/5074044 to your computer and use it in GitHub Desktop.
"De-Drupalizing The Login Form" correction Since the repository where Morten DK commited his code seems to be private, I decided to correct the code from his article and give my own twist to it. I also added more fixes, like not being able to see the "Create new account" link if the site does not allow user registrations and fixing not only the …
<?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;
}
@GitYili
Copy link

GitYili commented Apr 22, 2014

After I have added the code in my templete.php , a blank page appears with nothing on it. My Website does not seem to be running.

Please help me . Appreciated !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment