Profile edit form on same page as account information
Task · place profile account info and edit form on the same page · theme user profiles · Developers and coders · Site administrators · Themers · Drupal 6.x · No known problems
Last modified: August 26, 2009 - 22:18
Sometimes, you need to merge user account edit screen and profile values to one form. Here is a snippet how to do it.
Example:
You want to merge User edit form with My personal data section of the profile.
First, you need to create your own module. Implement hook_user():
/*
* Implementation of hook_user().
*/
function mymodule_user($op, &$edit, &$account, $category = NULL) {
switch ($op) {
case 'form':
// We are at edit screen. Load form data for "My personal data" category.
return profile_form_profile($edit, $user, 'My personal data');
break;
}
}Code above will merge these two forms together and display profile form on user edit screen.

It does work, but...
If there are more profile forms, the hook_user will add our 'My personal data' form to all profile sections. In order to avoid that it is possible to use this version of _user
/** Implementation of hook_user().
*/
function etsf_personal_info_user($op, &$edit, &$account, $category = NULL) {
if ($op == 'form' && $category == 'account') {
// We are at edit screen. Load form data for 'My personal data' category.
return profile_form_profile($edit, $user, 'My personal data');
break;
}
}
The only problem I have now is that the original 'My personal data' form is still displayed. I want to hide it.
In any case, thank you!
The only problem I have now
You can hide it with
ul.secondary {display:none;
}
However this will hide all secondary tabs.
You could also use custom template page-user-edit.tpl and comment out
<?php if ($tabs): print '<div id="tabs-wrapper" class="clear-block">'; endif; ?><?php if ($tabs): print '<ul class="tabs primary">'. $tabs .'</ul></div>'; endif; ?>
<?php if ($tabs2): print '<ul class="tabs secondary">'. $tabs2 .'</ul>'; endif; ?>
One Page Profile module
There is this useful module:
http://drupal.org/project/onepageprofile
that do the same in a better way.
Note that snippets in this page aren't working: they works only apparently, but all data are stored on $account->data instead of on {profile_values} database table (I've tested it directly adapting these snippets to Drupal 5.x, but not on 6.x).
That module solves this kind of issue, and many others are listed on issue queue http://drupal.org/project/issues/onepageprofile.
subscribing...
subscribing...
Can it be implemented with Content Profile?
I'm using Content Profile module to add extra CCK fields to the profile (Drupal 6.x). How can I merge it with the Account Information page?
Thanks a lot!