I am using Drupal 7 and I have added some code to my template.php file in my theme (which I found on a Drupal tutorial) so I can use a custom template for the user login form. The form works and it is using the custom template but it is generating these errors:

Notice: Undefined index: classes_array in template_process() (line 2527 of /includes/theme.inc).
Warning: implode(): Invalid arguments passed in template_process() (line 2527 of /includes/theme.inc).
Notice: Undefined index: attributes_array in template_process() (line 2533 of /includes/theme.inc).
Notice: Undefined index: title_attributes_array in template_process() (line 2534 of /includes/theme.inc).
Notice: Undefined index: content_attributes_array in template_process() (line 2535 of /includes/theme.inc).

The code I have in my template.php file is:

function cr_theme() {
  $items = array();

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

function cr_preprocess_user_login(&$vars) {
  $vars['forgot_link'] = l(t('Forgot password?'),'user/password');

and my user-login.tpl.php file contains:

<div class="cr-user-login-form-wrapper">
  <?php print drupal_render_children($form) ?>
<p style="margin-top:12px;"><?php print render($forgot_link); ?></p>

I have been trying to find the cause of the errors which I think is probably something I have not added to my cr_theme() function but now need some help.

3 Answers 3


By playing around with the preprocess function I seem to have fixed the errors. I changed the preprocess function to:

function cr_preprocess_user_login(&$vars) {
  $vars['content_attributes_array']['class'][] = 'content';
  $vars['title_attributes_array']['class'][] = 'content';
  $vars['attributes_array']['class'][] = 'content';
  $vars['classes_array'] = array('content');
  $vars['forgot_link'] = l(t('Forgot password?'),'user/password');

I just added in the undefined indexes that were coming up in the errors. I'm really not completely sure what I am doing but it does seem to be removing the errors so far.

It would be great if someone could comment how this is working.


I would try add back in all the default preprocess functions to the array, given that the system is whining about getting undefined indexes.

preprocess functions: A list of functions used to preprocess this data. Ordinarily this won't be used; it's automatically filled in. By default, for a module this will be filled in as template_preprocess_HOOK. For a theme this will be filled in as phptemplate_preprocess and phptemplate_preprocess_HOOK as well as themename_preprocess and themename_preprocess_HOOK.

  • Thank you cchen for taking the time to answer my query. I seem to have fixed it using the answer I have given, though I'm not completely sure how I managed it.
    – Ben
    Commented Jul 12, 2016 at 17:36
  • You're welcome @Ben glad you figured it out :)
    – cchen
    Commented Jul 12, 2016 at 18:34

I had exactly the same issue (guessing I found & used the same tutorial referenced in the question... :)

Based on the info provided by cchen, I simply removed the preprocess array info:

   'preprocess functions' => array(

Cleared cache, and that was it.

Also like you, I don't know enough about this stuff to understand why this worked. All I can do is confirm it did.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.