the block is shown on a site different from user or user/login.

Error message is:
•Notice: Undefined index: user_pass in drupal_retrieve_form() (line 736 of D:\xampp\htdocs\d7\includes\form.inc).
•Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'user_pass' not found or invalid function name in drupal_retrieve_form() (line 771 of D:\xampp\htdocs\d7\includes\form.inc).

To reproduce put the following code in a new block:

global $user;
if ($user->uid) { 
    //User is logged-in
    return "The Register/Login/ResetPassword block is only visible for anonymous users.";
} else {
    print drupal_render(drupal_get_form('user_register_form'));
    print drupal_render(drupal_get_form('user_login'));
    print drupal_render(drupal_get_form('user_pass'));
}

Comments

Nikdilis’s picture

the block is shown on a site different from user or user/login.

... or user/password (of course ;-) )

droplet’s picture

the function located at user.pages, you require to add this

module_load_include('inc', 'user', 'user.pages');

leave mature developer to decide if we need to improve or not .

berdir’s picture

Status: Active » Closed (works as designed)

I think this is by design.

As droplet pointed out, if you use a form defined in a file other than .module, you need to include it yourself.

Nikdilis’s picture

@droplet: Thank you.
Berdir, is it user friendly to leave it like that? A normal user of Drupal like myself might wonder why the error shows up.
She/He expects to be able to render any form with the drupal_render(drupal_get_form) function.
At least it needs documentation in my point of view.

berdir’s picture

Well, that's nothing new, many forms, for example node_form, were already moved to .pages.inc files in D6.

As I said above, when you use a form, you need to check where it is and include the file if necessary. Not sure where that should be documented.

amfriedman’s picture

This is unexpected, inconsistent behavior -- a "gotcha" -- given that you can output the login and registration forms just fine without including any additional file. I don't think this issue should be closed.

reign85’s picture

Subscribe, get thes same problem since updated the core to 7.23

JimoftheSlowclick’s picture

I agree with you on this. Just did exactly as you described.

JimoftheSlowclick’s picture

I just did exactly this, so I argue you're correct.

taggartj’s picture

Issue summary: View changes

this may help some one :


$output =' dogs have ears ! ';

drupal_set_title(t('Send me my password  '));
// include user form 
module_load_include('inc', 'user', 'user.pages');
$form = drupal_get_form('user_pass');
$output .= render($form);
Abhishek Verma’s picture

Thanks @droplet

Kumar Kundan’s picture

Thanks @droplet