Home › Forums › Feature Requests › Local fields defined by PHP : auto-generate unique keys › Reply To: Local fields defined by PHP : auto-generate unique keys
I’m not the developer, but one thing I can probably safely say is that Elliot is not going to add something that can be easily broken. Also, right now when ACF generates field keys it uses uniqid()
which just generates a string based on the current time.
To auto generate unique keys that will not change, ACF would need to know the parent, whatever that might be.
You might want to bring this up with the developer by contacting him here https://www.advancedcustomfields.com/contact/
I would create a function that takes a prefix/suffix for a field key
function custom_add_field($prefix) {
$field = array(
'key' => 'field_'.$prefix.'_12345678',
//.....
);
}
You might want to look into the way the ACF generates field keys for clone fields.
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.