Advanced Custom Fields – VERY powerful, but does have some warts

UPDATE: The warts seem to have healed… I’ve been able to import field groups on a clean install following this post. The plugin doesn’t always act like expected, but this functionality is working.

I recently needed to complete an overhaul of the way in which a site was updated, because the current method (I take whatever the departments submitted and fold it into the existing site) was unmanageable. Without an easy way to determine what had been changed from the previous version required either looking carefully at both versions of the data, or simply posting the new data, completely replacing the old data.

Unfortunately, since the new data was sometimes a complete rewrite of the old information and sometimes just an addendum to the previous information, and anything that was pasted into the site (from the PDFs provided) required extensive reformatting, and since some of the submissions could get quite long, neither of these solutions were very good. It seemed that there wasn’t any way to make consistent rules about how to handle the data submitted to me. Some was long and wordy, containing lots of sections not part of the original outline for the reports, while some were terse and did not contain all of the requested sections. Some were a complete rewrite, while some were an addendum, the placement of which in the original submission was not obvious.

There had to be a way to get the people who knew bout this information and where and how it should fit into the report to actually make these updates. Of course, the cold reality is that making everything look nice and consistent with reports from other units is not a  priority for each department and program. Their priority is to submit a yearly update to the report, and get back to their teaching mission as quickly and easily as possible.

In comes Advanced Custom Fields. Literally, this plugin creates a custom post type called ‘acf’, which is just a way to organize the various groups of fields that one wants to create into “field groups”. What it accomplishes is the ability to create highly customized post or page editing screens, with a wide range of different field types, from WYSIWYG text entry fields with a word processor-like toolbar, to check boxes, radio buttons, file upload fields, and a bunch of others, all with the capabilities usually found in form builders, like conditional formatting, validation (is that really an email address they typed in?), etc.

This is basically how it works:

  1. Download and install Advanced Custom Fields
  2. Click on the Custom Fields menu that appears in the WordPress admin area
  3. Create a new Field Group
  4. Start adding fields of various types (single-line text, text area, number field, date picker, etc.)
  5. Set some rules about when you want this Field Group to appear in someone’s Page or Post editor (eg: when a certain template is selected, all the childer of a specific page, when the default template is used, etc.)

That’s pretty much it. (Of course, these steps can get more complicated when you start figuring in conditional logic: show this field only when this checkbox is checked for instance, but to get started with it, these are the basic steps.

The main wart:

So, this plugin did an awful lot of what I wanted, all very neatly and provided a set number of fields, each with a title, description and even some sample text, so people can see what sort of information goes in there. It’s almost perfect, but there’s one specific feature I could never get to work. There are two ways to export the work you’ve done setting up a very fancy, full-featured Field Group, so you use it again on other sites. Unfortunately, the more powerful of these two methods, the XML export, never worked for me. This would allow someone to export the entire Field Group from one site, import it into another site, then modify and edit that Field Group in the new site just like it had been created there.

The problem is, it never worked. I tried and tried to figure out a way to get it to work, creating and destroying WP instances on my local machine to make sure I wasn’t tainting my results with leftover mistakes I’d made in trying to get it to work.

There is also a PHP export, which basically exports code to manually create each of the fields in the field group, with each of the settings specified directly in the PHP. One takes the PHP and pastes it into the functions.php file on the target site (on which they have ACF installed) and the field groups are available. They just can’t be easily changed anymore, without going back to the site on which they were created, and exporting the PHP again. Not a single preference or option can be changed without either modifying the PHP manually or going to the original site to make the changes and re-export the PHP.

All in all, a little bit of a pain in the neck, but a very powerful plugin. I was able to create a page editor screen that is basically fill-in-the-blank, which shouldn’t be too onerous a task, even for busy professors or administrators. (And the developer of the plugin seemed to be a conscientious person, so hopefully he’ll get the export to XML working in a future version.)

Related Posts: