User defined profiles that appear on the registration form do not save when a new user is created. The values get cached, but if you examine the database they are not there. The problem is that profile_user receives the 'insert' but only for the account. Any profile fields are not included. What needs to happen on insert is that all categories need to be passed to the profile_save_profile routine. The following code will fix this.
function profile_user($type, &$edit, &$user, $category = NULL) {
...
case 'insert':
return profile_save_profile_new($edit, $user, $category);
...
}
function profile_save_profile_new(&$edit, &$user, $category) {
$result = db_query('SELECT DISTINCT(category) from {profile_fields}');
while ($field = db_fetch_object($result)) {
profile_save_profile($edit, $user, $field->category);
}
}
I have attached my version of profile.module. It includes a couple of other changes such as theming the table output.
Comments
Comment #1
chx commentedPlease read http://drupal.org/patch .
Comment #2
swood commentedI hadn't provided a patch because my copy has a couple of other changes people might not be interested in. I have attached a patch which will affect the following:
1. I've themed the table output.
2. I've removed the restriction on the sql query to only get users who have logged in. It seemed to me that if I want a user list, then I want them all. I can restrict those users on output if desired.
3. Added the profile_save_profile_new to correct the problem preventing new adds from adding category info.
Comment #3
jim_fulford commentedI've noticed that the same thing happens on Update,
In Drupal 5, create Profiles that span muliple pages / categories
Create User and SAve, everything is OK
Go to any page of the profile fields and edit and save.
The fields on that page are OK, but the others profile fields are lost.
Comment #4
jim_fulford commentedI was able to correct this by adding a break after the Update, in the profile.module, the
return profile_save_profile_new($edit, $user, $category);
was running for the update and the insert causing the issue.
Comment #5
swood commentedI'm not sure why a break would have been needed. The code that I have is:
The update should never have fallen into the insert code but would have simply executed the original function and returned.
Comment #6
panchoIn case I'm wrong, please reopen or mention this as a subsequent bug on http://drupal.org/node/119114.