I updated from the latest 4.x ACF to ACF Pro, cause I wanted to 😉 And some extra development needed it.
There is only one small issue – I made the upgrade per instructions, upgrade/backup of database.
Everything seems fine, but there is only one field that causes problem. Everything else works as before.
This row does not work, it did before:
update_field(‘field_8’, $data[‘maxRent’], $ID);
-> The line of code does not work at this time. I got plenty of update_field like this before and after in my php-file for the other fields. And ALL of them work. $data[‘maxRent’] has a value, and I have also set an hardcoded string here.
But the value appears empty when retrieveing it, and setting it.
I have assigned all fields to a custom post type, so they can all easily be altered in admin.
But only this one field – field_8 makes no success in setting or retrieving nor in the admin or from the frontend-field.
I have made some debugging, but I can not get down to the issue in fixing this one thing. Strange.
Any experience from you people perhaps? I got like a couple of thousands entries made previously..
the field_8 is a plain simple Text field, and I got like many fields, causing no issues else where..
I might have made a discovery here, but am not sure.
I got a field_8 used in another ‘Field Group’ as well.
Must they be totally unique?
I guess so?
It worked with the 4.x ACF though, but the upgrade now might have thrown in some issued of course.
So I got like this now:
Galllery Field Group > img (field_8)
Interest form Field Group > maxRent (field_8)
How can I make the field_8 for the img gallery to be completely unique?
Do I have to make changes in database, or is there a better way?
Is field_8
the field name or the field key?
If it’s the field key, then yes the problem is because you have two different field types using the same key, these must be unique.
If it is the field name, then the problem is that it starts with field_
. Field names cannot begin with field_
It is the Field_Key unfortunately.
I guess the newer versions of AFC has more random generation of the field_keys.
I guess I would like to have a “database upgrade”/”upgrade” or a “Fix duplicated field keys”-button/function to solve this.
Making a database-hack, and many manual steps to fix this does not seem like a solution that I would feel confident in. Even though I understand somewhat steps on how to achieve a fix.
There should be an internal check which could be viewed within the admin about notices/warnings.
I remember this as a problem earlier when importing/exporting ACF groups from places, or the need for duplicating etc etc.
I wish this could be added some more checks in current version as well, especially when it comes to upgrades and other things like that 😉
Unfortunately, I don’t know of any way to easily fix the problem.
If the field names are unique that would make it a little easier. Even here, if the field is part of a repeater or flexible content field it’s not going to be simple. The following SQL query would do the work. You’d need to swap out the table and field names to match your after changing one of the field keys.
In the following
acf_field_name = '_'.$your_field_name
UPDATE wp_postmeta SET meta_key = "acf_field_name"
, meta_value = “new_field_key” WHERE meta_key = “OLD_acf_field_name” AND meta_value = “old_field_key”
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!
ACF wouldn’t be so widely used in WordPress if it didn’t have some pretty amazing capabilities. In this article, we look at a few of the features we’ll discuss during “7 things you didn’t know you could do with ACF” at #WPEDecode later this month. https://t.co/5lnsTxp81j pic.twitter.com/Yf0ThPG1QG
— Advanced Custom Fields (@wp_acf) March 16, 2023
© 2023 Advanced Custom Fields.
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.