Hi Guys - I am having an issue, while I'm trying to override the "Edit Profile" form. I need a separate URL for edit profile of the user. For this, I have created a URL using Module's hook_menu hook. In the page callback function, i'm trying to load the form using the below code:

function edit_profile() {
global $user;
$output=drupal_render(drupal_get_form('user_profile_form'));
return $output;
}

But, it's just giving me below errors and not returning me the form. Can anyone guide me please.

Notice: Undefined index: user_profile_form in drupal_retrieve_form() (line 750 of C:\wamp\www\flexia\includes\form.inc).
Warning: call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, 'user_profile_form' was given in drupal_retrieve_form() (line 785 of C:\wamp\www\flexia\includes\form.inc).

Thanks,

Comments

rviverma’s picture

Hi Guys - Can anyone please help me on this? Thanks in advance.

arrakis83’s picture

The problem is that the user_profile_form is located in user.pages.inc.
This should work :

module_load_include('pages.inc', 'user', 'user');
global $user;
$output = drupal_render(drupal_get_form('user_profile_form', $user));
return $output;

To better understand it, check the user.module, hook_menu().
Ex:

$items['user/%user/edit'] = array(
  'title' => 'Edit',
  'page callback' => 'drupal_get_form',
  'page arguments' => array('user_profile_form', 1),
  'access callback' => 'user_edit_access',
  'access arguments' => array(1),
  'type' => MENU_LOCAL_TASK,
  'file' => 'user.pages.inc',
);
Svekke’s picture

This works great. You can add the profile to a page.
But i also use the profile2 module. How can i add that to a page.
I can't get it working.

Svekke’s picture

Sorry, double post!

rviverma’s picture

Hi Arrakis83 - Thanks alot. You are a Gem in Drupal.

Thanks,
Ravi Verma

HydroZ’s picture

as you pass the user object to the functions that will generate the form, make sure, that all information are loaded to the passed parameter:


  module_load_include('pages.inc', 'user', 'user');
  global $user;
  $account = user_load($user->uid);
  $output = drupal_render(drupal_get_form('user_profile_form', $account));
  return $output;