Support

Account

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.