Print or render Drupal user account profile form anywhere

Code below allows you to render the Drupal user edit form anywhere. Replace UID with the user account ID to edit.

$account = user_load(UID);
module_load_include('inc', 'user', 'user.pages');
$form_state = array();
$form_state['build_info']['args'] = array($account);
form_load_include($form_state, 'inc', 'user', 'user.pages');
print render(drupal_build_form('user_profile_form', $form_state));

4 comments for 'Print or render Drupal user account profile form anywhere'

yakoub's picture

you should call drupal_get_form and not drupal_build_form
no need for form_load_include

Add new comment