Hi All,
This module helped me a lot but the Profile field values are lost when I perform bulk operations(block-unblock user in my case) on registered users in User management if the module is enabled. This is not so when I disable the module.
Thanks.
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | onepageprofile_543434.patch | 791 bytes | petebarnett |
Comments
Comment #1
petebarnett commentedAfter experiencing similar problems with profile fields disappearing when
user_save()is called, I investigated further...onepageprofile_user()makes the assumption that hook_user update is only be invoked as a result of editing the profile via a form, however it is also invoked byuser_save().It seems acceptable that
user_savecould be called simply to edit user roles, or some other user field, however onepageprofile still callsprofile_save_profile()for all profile category regardless.The result being that the core profile module deletes all fields in every profile category, having nothing to replace them with.
I have temporarily solved this by checking the
$editarray for the presence of any field starting with 'profile_', however I feel there may be a better solution. I will post a patch with anything I come up with.Peter
Comment #2
jaxond commentedSame problem occurs when Logintobaggan does a role change when a new user clicks on his/her emailed registration validation link. All the profile_values data is erased and rows with empty values are created for all the profile_values fields.
Comment #3
petebarnett commentedYes, this is what originally caused me problems. I assumed it was a LoginToboggan bug and implemented a hack, however it is apparent that the onepageprofile module is updating categories that aren't being edited.
We simply need the module to check whether there have been any updates to each category before calling profile_save_profile()
Comment #4
sethcohn commentedPeter, got a patch yet?
Comment #5
petebarnett commentedhere's my patch...
To clarify the problem, the core profile module handles the saving of profile fields in
hook_userupdate with its own function,profile_save_profile.This function deletes all existing field values in the category being edited ($category, as passed into
hook_user), before re-populating with the values passed through in the$editarray.onepageprofile's
hook_userupdate op assumes that the account is being edited from the profile form, and so loads all the categories, actively callingprofile_save_profile. This is fine, as when the form is submitted, all profile categories are available, and will be updated.If however, the user update hook is invoked directly, via
user_module_invoke, or as part ofuser_saveonly one category will be set - normally 'account'. onepageprofile callsprofile_save_profilefor all categories, causing all the values to be deleted, with nothing there to replace them.To solve this, we just need to know what context the user update is being called in: the profile form (all categories available, so we can proceed as before), or some other way - we don't need to do anything.
As
user_profile_form_submit(the submit handler for our profile form) simply passes the $form_state['values'] through as the $edit array, it contains a 'form_build_id'. This patch simply checks for the existence of the form_build_id to establish that we're being edited from the profile form, and not by some other method.Peter
Comment #6
MMachnik commented+1 on this -- I can confirm the patch works. Thanks!
Comment #7
aidanlis commentedGreat detective work! I've rolled a new version and released it. Thanks very much peterbarnett.
Comment #8
whan commentedHi,
Thanks Peter your patch worked.
Comment #9
aidanlis commentedComment #10
drupaul.z commentedThank you very much.
It works.