Support

Account

Home Forums General Issues creating field groups from inside my plugin

Solving

creating field groups from inside my plugin

  • I am creating a custom plugin which will be dependent on ACF. I dont really want to include ACF in my plugin, so I have a check on the activation hook to ensure that ACF is installed and active. That part works well.

    My next step is that I would like to have my plugin create an ACF field Group, if it doesn’t already exist.

    I have done a lot of googling and havent been able to come up with too much for this. Most people seem to be including the ACF plugin in their plugin.

    also at the moment, I am using the free version of ACF I plan to get the paid version, but only after I get the development of my plugin done.

  • First, the free version and the Pro version work differently at the moment, so the method of doing this would be different.

    In the pro version there is a function acf_get_field_groups() that can be used to get a list of field groups.

    In the free version there is a filter that can be used, $field_groups = apply_filters('acf/get_field_groups', array());

    You’ll need to look into the ACF code to get more details.

    I usually do this on the ACF Pro hook “acf/include_fields” with a high priority so that all other fields groups are already included before I check to see what field groups already exist.

    A word of caution. I have had this interfere with other plugins. I’ve had this happen recently with a site and all of the problems were with plugins created by https://yithemes.com/

  • Thanks for the reply!

    That definitely works to get be the list of existing acf field groups. Now I need to be able to create a new field group and fields using ACF free. How would I go about doing that?”

  • I have just set up the local json feature and I have the json files in the acf-json folder in my theme root. However, when I manually modify one of the json files (changing the field group title for instance), that change is not reflected in the ACF GUI. Is that somethgin that woudl only work in ACF pro?

  • The free version of ACF (ACF4) does not support local json files. This is only a feature of ACF5. The only way to create field groups in ACF4 is using PHP.

Viewing 6 posts - 1 through 6 (of 6 total)

The topic ‘creating field groups from inside my plugin’ is closed to new replies.