Custom theme admin login Drupal 7

505 views Asked by At

I have a problem using Drupal 7 admin login in my custom theme. After creating a custom theme when I try to submit the login form, I receive the following error:

"Access denied You are not authorized to access this page."

When I revert back to a default theme (eg. Bartik), everything works fine again.

After reading a lot of solutions, I can't seem to find the right one for me. Any ideas?

EDIT: The problem seems to be the "drupal_render(drupal_get_form('search_block_form'))" in my page.tpl.php. For my theme i need a form markup without any container, so i used this function to render the form. The solution for me was to change it like:

$form_array= drupal_get_form("user_login"); 
$form = drupal_render($form_array);
echo $form;
1

There are 1 answers

0
Ataboy Josef On

First take a look at this: your-drupal-parh/user -if this link takes to the login form, then you just need to customize the login form.

If it doesn't help, try create a login.

Update templete.php

function themename_theme() {
  $items = array();
  $items['user_login'] = array(
    'render element' => 'form',
    'path' => drupal_get_path('theme', 'themename') . '/templates',
    'template' => 'user-login',
    'preprocess functions' => array(
       'themename_preprocess_user_login'
    ),
  );
  return $items;
}

function themename_preprocess_user_login(&$vars) {
  $vars['intro_text'] = t('Custom login form');
}

themename is the name of your theme. path points to the path where the user-login.tpl.php file exists in your theme directory[here drupal_get_path('theme', 'themename') . '/templates' means that the user-login.tpl.php file is in the theme's template directory].

Code for user-login.tpl.php:

<p><?php print render($intro_text); ?></p>
<div class="redha-user-login-form-wrapper">
  <?php print drupal_render_children($form) ?>
</div>

Clear cache and see what happens.