I'm trying to position my login block in my page.tpl file. Everytime I insert the code

<?php print drupal_render(drupal_get_form('user_login')); ?>

in my page.tpl file. It throws an error. The error it throws is

Strict warning: Only variables should be passed by reference in include() (line 79 of C:..\sites\all\themes\neptune\templates\page.tpl.php).

How can I fix this issue?

  • what error it throws?
    – xurshid29
    Sep 18 '14 at 6:36
  • Strict warning: Only variables should be passed by reference in include() (line 79 of C:\..\sites\all\themes\neptune\templates\page.tpl.php).
    – newbie
    Sep 18 '14 at 6:39
  • @nabeela you should add the details to your post. Please edit your question and add details.(instead of in comments) Sep 18 '14 at 6:41
  • Sorry about that @KrishnaMohan
    – newbie
    Sep 18 '14 at 6:43
  • @nabeela nothing to be sorry about that. I just wanted to notify you. :) Sep 18 '14 at 6:44

You can do it like this:

if(!user_is_logged_in() ){
    $userLoginForm = drupal_get_form('user_login');
    print drupal_render($userLoginForm);

because drupal_render receives argument as reference..

  • thanks it worked. If you don't mind telling me..is there a way to change the style of the form?
    – newbie
    Sep 18 '14 at 7:24
  • @nabeela what style? With CSS you mean?
    – xurshid29
    Sep 18 '14 at 7:37
  • When I put this code, the only thing I see is the username, password and submit fields. the "Register" and "Forgot your Password" fields are not there. So how can include that in this
    – newbie
    Sep 18 '14 at 7:42
  • ok, I understand. You should include User login block instead of User login form to your .tpl.php file..
    – xurshid29
    Sep 18 '14 at 7:48
  • Yess thats exactly what I want..how do I include that user login block in my page.tpl.php?
    – newbie
    Sep 18 '14 at 7:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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