1

I have used default user login block on top navigation. I need to load another log in form on some pages.

I am trying to load the form by

drupal_get_form('user-login')

I get the following error:

Notice: Undefined index: user-login in drupal_retrieve_form() (line 763 of /path/to/drupal/includes/form.inc). Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'user-login' not found or invalid function name in drupal_retrieve_form() (line 798 of /path/to/drupal/includes/form.inc).

Is it possible to load a second log in form? (Drupal 7)

  • Do you mean you want two log-in blocks/forms on the same page? – Patrick Kenny Feb 1 '13 at 0:43
  • Yes, One is on top navigation on all pages. Second one will be on some pages where there is a password protected content. – 15dk51 Feb 1 '13 at 0:48
  • You can use the LoginToboggan module if you want to show a login form when users do not have appropriate permission. Just check the setting for "show login form on access denied." drupal.org/project/logintoboggan – Patrick Kenny Feb 1 '13 at 0:55
3

The key point in the error message is:

...expects parameter 1 to be a valid callback, function 'user-login' not found

You need to use:

drupal_get_form('user_login');

Where user_login is the form builder function in this case.

e.g:

print render(drupal_get_form('user_login')); 

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.