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.

CommentFileSizeAuthor
#2 profile_module.patch4.48 KBswood
profile_11.module32.81 KBswood

Comments

chx’s picture

swood’s picture

StatusFileSize
new4.48 KB

I 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.

jim_fulford’s picture

I'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.

jim_fulford’s picture

I 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.

swood’s picture

I'm not sure why a break would have been needed. The code that I have is:

...
    case 'update':
      return profile_save_profile($edit, $user, $category);
    case 'insert':
	  return profile_save_profile_new($edit, $user, $category);
...

The update should never have fallen into the insert code but would have simply executed the original function and returned.

pancho’s picture

Status: Active » Closed (duplicate)
  1. As the original bug is being more extensively covered on http://drupal.org/node/119114, I mark this one here as duplicate.
  2. The subsequent bug covered in Jim's comment #3 I can't replicate. On my clean 5.x-dev install, profile data doesn't get lost when first editing it. It's just not being completely moved to table {profile_values}. Values in unedited categories are remaining "cached" in the {users} table.

    In case I'm wrong, please reopen or mention this as a subsequent bug on http://drupal.org/node/119114.