Home Forums ACF PRO Using ACF Pro in plugin when standalone already installed


Using ACF Pro in plugin when standalone already installed

  • We are considering including ACF Pro in our plugin for adding fields to a Custom Post Type the plugin will be using, and before we get started, we would like to know if there are any issues related to using ACF Pro in a plugin when the possibility exists that the site already has ACF Pro or Free installed. We’ve read through and searched the forums and documentation and haven’t seen this concept referenced.

    Primarily, we would like to be able to hide the admin menu using the ‘acf/settings/show_admin’ filter when ACF is not installed, but not prevent the admin when ACF is installed. The concern is that we will be overriding the standalone PRO Admin menu.

    Tangentially, is there a way to use ACF Pro in a plugin when there is also a standalone ACF installed on the site, and hide the Field Groups we are using for our plugin’s custom post type from the Admin Menu?

    Thank you, and sorry if this has been covered before.

  • I’m assuming that you already read that you can only include ACF Pro in a premium plugin. So that aside.

    You can have ACF installed normally and part of a plugin, there won’t be a problem if they are the same version.

    You cannot run ACF Pro and ACF 4 on the same site. Only one of them will be active.

    Which version will be active is a function of WP and the order that the plugins are loaded. WP includes plugins in the order they were installed, usually, I think, sometimes it’s unclear. But when there are plugins installed normally as well as plugins installed as part of other plugins and those plugins take the care to make sure they’re not already installed before running (like ACF) then whoever is included first wins.

    You’re best bet would be to have a function that’s called on the WP hook “plugins_loaded” and test to see if ACF is already installed. This would be a way to avoid problems with ACF4 being installed. I suppose that you could then deactivate 4 at that point letting the admin know what was done. Showing or hiding the ACF admin menu would need additional testing… is ACF installed, what version was installed, did you deactivate 4, there would be a lot of variables to consider.

    Hiding the ACF field groups from someone that has access to ACF would be difficult, or maybe impossible, if the field groups are in the DB. To avoid allowing the user to edit these fields you’d need to export them and include your field groups in code.

  • Yea we know about the licensing for this.

    After reading your notes about versioning, we confidently think we can determine the ACF version minimum requirements, and if the plugin is there and the minimum version isn’t >= our needed version fire up an admin_notice.

    I think the ultimate answer lies in using exported code and avoiding the DB for addding fields to the custom post type.

    Looking at seems to be the right direction. Does exporting to PHP (or json) prevent end users from manipulating the fields?

  • With ACF Pro, if I need to keep field groups editable in my dev site where I develop plugins so that I can alter them I use JSON files for the field groups in a local JSON file in the plugin. Then I test to see if the field groups exist with a higher priority than ACF uses and if the don’t exist I load the JSON files and add them that way. I do this when I think I might need to change them, although, once you’ve done it enough it’s almost as easy to change them in code, though it get’s complicated when there’s a lot of conditional logic.

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

The topic ‘Using ACF Pro in plugin when standalone already installed’ is closed to new replies.