Home › Forums › Backend Issues (wp-admin) › A user meta field won’t get saved for SOME users
I have a large user database (around 250) and I used ACF to create 23 extra user fields like company name and membership description etc.
These users and their user metas were all imported with another plugin (https://wordpress.org/plugins/import-users-from-csv-with-meta/) that worked perfectly. I checked the database and the values showed up fine.
My membership description is a radio (also tried select and text) type input where I can set what kind of membership she has.
For SOME users no matter what I choose and save, when the page refreshes it will always revert to the first option, thus the data doesn’t get saved.
When I actually look at the database the data does not get updated for these users! They can only be modified through the database. Of course, the data still won’t show up right in the wp user profile.
Again, this only happens for some of the users, and other users’ membership_description meta could be updated just fine through the wp users menu.
I have tried:
– Disabling cache
– Triple checked the name of the user_meta, no error there
– Tried text, select, radio input types
– Tried setting Return Value to all three options ACF offers
– Tried creating other user metas with select and radio and they always work
– Have not used validation or sanitization
– Have not used conditions
– Checked the database columns in phpmyadmin, no errors
– ACF plugin is up to date
– Checked my permission, as an admin I have the right to update user profiles, and I can actually do that for every other fields, except for this one on SOME profiles.
I have checked my wp_user_meta database column and it has over 17,000 rows. Could that be somehow a database issue? Or could it be a plugin/theme conflict?
I’d appreciate any advices and suggestions.
Whatever issue you are having that issue is going to be with the import plugin you are using and not with ACF.
There are some specific things that could be causing the issues that you are describing.
The fist is that the other plugin is not saving the correct acf field key reference in the database. The field key reference is saved with a meta key that matches the field name and is prefixed with an undersore (_) "_{$field_name}"
and the value of this field is the field key of the associated ACF field.
ACF expects each meta key to have exactly one entry in the database. Saving but reverting to a previous value is a symptom of having multiple entries in the database for the user with the same meta key.
Another cause of saving an reverting to some other value can be the existence of multiple fields with the same name (meta_key). ACF field names must be unique.
Okay, so I double-checked again, for my membership_description meta key I get this field key reference: _membership_description right?
it comes with the value: field_6357a757b976d
Triple-checked there are no other meta_keys with this name for the examined user_id.
I listed all of my users in phpmyadmin, and the key-value pair matched for each and every user, so everyone has the same DB entries.
I tried:
1. Deleting the field key reference value in the database
2. Deleting the the field key value in the database
3. Refreshed this user’s wp profile and found that the value was set to the default option, like it should.
Then:
4. In the wp profile I chose a different option and saved it.
5. The profile was still showing the default value, so no change, but in the database I see the new value now, the one that I just chose and saved.
6. Also, when I saved the profile the field key reference value was reverted to its original value: field_6357a757b976d
But you are right, this only happens with the imported users. Those who registered themselves the issue doesn’t occur.
So what else could be blocking this wp user profile field (and only this) to get the right value from the database?
Other fields like this work fine.
Are the fields with an issues top level fields or are they sub fields of one of the field types that has sub fields?
I don’t know anything about sub-fields.
I generated the entire field group for you in php (it’s in a foreign language):
We are talking about the very first item ‘label’ => ‘Tagsági forma’,
‘name’ => ‘tagsagiforma’
It looks like any other field, I have fields with checkboxes and select type inputs, but they all work. Also tried re-ordering it.
add_action( 'acf/include_fields', function() {
if ( ! function_exists( 'acf_add_local_field_group' ) ) {
return;
}
acf_add_local_field_group( array(
'key' => 'group_634d783826828',
'title' => 'Felhasználó extra információk',
'fields' => array(
array(
'key' => 'field_6357a757b976d',
'label' => 'Tagsági forma',
'name' => 'tagsagiforma',
'aria-label' => '',
'type' => 'radio',
'instructions' => 'A felhasználó tagsági formája',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'choices' => array(
'Egyéni tag' => 'Egyéni tag',
'Céges tag' => 'Céges tag',
'Pártoló tag' => 'Pártoló tag',
'Tiszteletbeli tag' => 'Tiszteletbeli tag',
'Tiszteletbeli alelnök' => 'Tiszteletbeli alelnök',
),
'default_value' => '',
'return_format' => 'array',
'allow_null' => 0,
'other_choice' => 0,
'layout' => 'vertical',
'save_other_choice' => 0,
),
array(
'key' => 'field_6357ac1d21e26',
'label' => 'Egyéni vállalkozó v. magánszemély? (Csak Egyéni tag esetén értelmezendő)',
'name' => 'ev',
'aria-label' => '',
'type' => 'select',
'instructions' => '',
'required' => 0,
'conditional_logic' => array(
array(
array(
'field' => 'field_6357a757b976d',
'operator' => '==',
'value' => 'Egyéni tag',
),
),
),
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'choices' => array(
'Egyéni vállalkozó' => 'Egyéni vállalkozó',
'Magánszemély' => 'Magánszemély',
),
'default_value' => false,
'return_format' => 'array',
'multiple' => 0,
'allow_null' => 0,
'ui' => 0,
'ajax' => 0,
'placeholder' => '',
),
array(
'key' => 'field_6357ae2621e27',
'label' => 'Cégnév',
'name' => 'cegnev',
'aria-label' => '',
'type' => 'text',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'default_value' => '',
'maxlength' => '',
'placeholder' => '',
'prepend' => '',
'append' => '',
),
array(
'key' => 'field_6357afc99687e',
'label' => 'Telefonszám',
'name' => 'telefonszam',
'aria-label' => '',
'type' => 'text',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'default_value' => '',
'maxlength' => '',
'placeholder' => '',
'prepend' => '',
'append' => '',
),
array(
'key' => 'field_643fb0d418590',
'label' => 'Telefonszám (vonalas)',
'name' => 'telefonszam_2',
'aria-label' => '',
'type' => 'text',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'default_value' => '',
'maxlength' => '',
'placeholder' => '',
'prepend' => '',
'append' => '',
),
array(
'key' => 'field_6357afd39687f',
'label' => 'Beosztás',
'name' => 'beosztas',
'aria-label' => '',
'type' => 'text',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'default_value' => '',
'maxlength' => '',
'placeholder' => '',
'prepend' => '',
'append' => '',
),
array(
'key' => 'field_6357ae3521e28',
'label' => 'Adószám',
'name' => 'adoszam',
'aria-label' => '',
'type' => 'text',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'default_value' => '',
'maxlength' => '',
'placeholder' => '',
'prepend' => '',
'append' => '',
),
array(
'key' => 'field_634d7887cddb9',
'label' => 'Tagozatok',
'name' => 'tagozatok',
'aria-label' => '',
'type' => 'checkbox',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'choices' => array(
'Vámtagozat' => 'Vámtagozat',
'Jövedéki Tagozat' => 'Jövedéki Tagozat',
'Környezetvédelmi Tagozat' => 'Környezetvédelmi Tagozat',
'Integrátori Tagozat' => 'Integrátori Tagozat',
'Informatikai Munkacsoport"' => 'Informatikai Munkacsoport"',
'Adóügyi Munkacsoport' => 'Adóügyi Munkacsoport',
'Nemzetközi Munkacsoport' => 'Nemzetközi Munkacsoport',
'Trade Compliance Munkacsoport' => 'Trade Compliance Munkacsoport',
),
'default_value' => array(
),
'return_format' => 'value',
'allow_custom' => 0,
'layout' => 'vertical',
'toggle' => 0,
'save_custom' => 0,
'custom_choice_button_text' => 'Add new choice',
),
array(
'key' => 'field_6357aea296874',
'label' => 'Irányítószám',
'name' => 'iranyitoszam',
'aria-label' => '',
'type' => 'text',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'default_value' => '',
'maxlength' => '',
'placeholder' => '',
'prepend' => '',
'append' => '',
),
array(
'key' => 'field_6357aeac96875',
'label' => 'Település',
'name' => 'telepules',
'aria-label' => '',
'type' => 'text',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'default_value' => '',
'maxlength' => '',
'placeholder' => '',
'prepend' => '',
'append' => '',
),
array(
'key' => 'field_6357aeb296876',
'label' => 'Utca, házszám',
'name' => 'utca',
'aria-label' => '',
'type' => 'text',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'default_value' => '',
'maxlength' => '',
'placeholder' => '',
'prepend' => '',
'append' => '',
),
array(
'key' => 'field_6357aec896877',
'label' => 'Emelet, ajtó, stb.',
'name' => 'emelet',
'aria-label' => '',
'type' => 'text',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'default_value' => '',
'maxlength' => '',
'placeholder' => '',
'prepend' => '',
'append' => '',
),
array(
'key' => 'field_6357aed596878',
'label' => 'Logó feltöltés',
'name' => 'logo',
'aria-label' => '',
'type' => 'image',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'return_format' => 'array',
'library' => 'all',
'min_width' => '',
'min_height' => '',
'min_size' => '',
'max_width' => '',
'max_height' => '',
'max_size' => '',
'mime_types' => '',
'preview_size' => 'medium',
),
array(
'key' => 'field_6357af0196879',
'label' => 'Fő tevékenység',
'name' => 'tevekenyseg',
'aria-label' => '',
'type' => 'text',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'default_value' => '',
'maxlength' => '',
'placeholder' => '',
'prepend' => '',
'append' => '',
),
array(
'key' => 'field_6357af249687a',
'label' => 'Tevékenység leírás',
'name' => 'tevekenysegleiras',
'aria-label' => '',
'type' => 'textarea',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'default_value' => '',
'maxlength' => '',
'rows' => '',
'placeholder' => '',
'new_lines' => '',
),
array(
'key' => 'field_6357af4a9687b',
'label' => 'Alkalmazottak száma',
'name' => 'alkalmazottak',
'aria-label' => '',
'type' => 'select',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'choices' => array(
'0-10 fő' => '0-10 fő',
'11-50 fő' => '11-50 fő',
'51-250 fő' => '51-250 fő',
'250 fő felett' => '250 fő felett',
),
'default_value' => false,
'return_format' => 'array',
'multiple' => 0,
'allow_null' => 0,
'ui' => 0,
'ajax' => 0,
'placeholder' => '',
),
array(
'key' => 'field_6357a920a5bd4',
'label' => 'Számlázási ciklus',
'name' => 'szamlaciklus',
'aria-label' => '',
'type' => 'select',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'choices' => array(
'Évente' => 'Évente',
'Fél évente' => 'Fél évente',
),
'default_value' => false,
'return_format' => 'value',
'multiple' => 0,
'allow_null' => 0,
'ui' => 0,
'ajax' => 0,
'placeholder' => '',
),
array(
'key' => 'field_6357af8b9687c',
'label' => 'Levelezési cím',
'name' => 'levelezes',
'aria-label' => '',
'type' => 'text',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'default_value' => '',
'maxlength' => '',
'placeholder' => '',
'prepend' => '',
'append' => '',
),
array(
'key' => 'field_6357afab9687d',
'label' => 'Megrendelés szám',
'name' => 'megrendelesszam',
'aria-label' => '',
'type' => 'text',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'default_value' => '',
'maxlength' => '',
'placeholder' => '',
'prepend' => '',
'append' => '',
),
array(
'key' => 'field_6357b5b74ff89',
'label' => 'Logó használat?',
'name' => 'logohasznalat',
'aria-label' => '',
'type' => 'true_false',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'message' => 'Az MVSZ a weboldalon megjelenítheti a logómat. (Ha ennek engedélyét utólag szeretné visszavonni, kérjük lépjen kapcsolatba munkatársunkkal)',
'default_value' => 0,
'ui' => 0,
'ui_on_text' => '',
'ui_off_text' => '',
),
array(
'key' => 'field_6357b487652c4',
'label' => 'Hír megjelenés?',
'name' => 'hirmegjelenes',
'aria-label' => '',
'type' => 'true_false',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'message' => 'Az MVSZ a weboldalon rövid hírt jeleníthet meg a csatlakozásomról.',
'default_value' => 0,
'ui' => 0,
'ui_on_text' => '',
'ui_off_text' => '',
),
array(
'key' => 'field_643fafdc0972f',
'label' => 'Megjegyzések',
'name' => 'megjegyzes',
'aria-label' => '',
'type' => 'textarea',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'default_value' => '',
'new_lines' => '',
'maxlength' => '',
'placeholder' => '',
'rows' => '',
),
),
'location' => array(
array(
array(
'param' => 'user_form',
'operator' => '==',
'value' => 'all',
),
),
),
'menu_order' => 0,
'position' => 'normal',
'style' => 'default',
'label_placement' => 'top',
'instruction_placement' => 'label',
'hide_on_screen' => '',
'active' => true,
'description' => '',
'show_in_rest' => 0,
) );
} );
I have no idea. If the other fields are working I see not reason for this field not to work.
Well, thanks anyway. I ended up renaming the field and that solved it. Guess we’ll never know what was the problem.
if renaming the field corrected it then these are the only possible explanations.
1) There was a conflict with some other field. This field could be an ACF field or any other field created by any other plugin or WP
2) There was a stray value somewhere in the database saved using that meta_key “tagsagiforma” that was not deleted correctly when the value was updated. Do to the way ACF stores and gets values if this meta_key exists more than once only the oldest saved value will be retrieved by ACF.
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.