Field Values Getting Erased After Submission with Gravity View When Run wp_update_user

I’m running into a very odd issue. When editing an entry using Gravity View the values entered for three fields is getting erased when the entry is saved. Two fields always getting erased. A third field only gets erased if a selection is made for one of the other two fields. Now where this gets really strange is that the erasure happens when I run the WordPress code

wp_update_user( $userData );

This happens even if all I send as the $userData array is the user ID, meaning no change is made to the actual user data. A log of the data in the entry just before I run wp_update_user shows the correct data in the fields in question and another log just after running wp_update_user shows that the data in the fields in question has been erased. And to further deepen the mystery, the fields that are getting erased are not fields that relate to any of the core user data in WordPress. So why is running the function wp_update_user affecting the data for a Gravity Forms form entry?

If anyone has any insights as to what might be going on here or how to work around it, please let me know. Thanks!

Edited to add: the work-around I’ve found for now is once wp_update_user is done I then use GFAPI::update_entry_field to populate the fields that are getting wiped away with the correct data. I’d rather stop the issue from happening in the first place but so far this is the best solution I’ve been able to find.

Hi Bruce,

Is there a chance that those two fields getting erased are hidden on GravityView’s Edit Entry page? Please check this: Conditional Logic on the Edit Entry page - GravityKit Support, Knowledge Base, How-To & Docs

For further debugging purposes, you can use these two filters below:

// Prevents GravityView from editing user data when form is connected to a User Registration add-on feed
add_filter( 'gravityview/edit_entry/user_registration/trigger_update', '__return_false' );
// Prevents GravityView from erasing any hidden field data
add_filter( 'gravityview/edit_entry/unset_hidden_field_values', '__return_false');

Please feel free to reach us at https://www.gravitykit.com/support/ for further assistance.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.