I hardly felt that ~20 lines of code is worth an entire blog post. So why are you able to read this as more than a tweet? The more I looked back at the potential approaches to solve this problem I could have taken, the more I realized understanding how to figure out the minimum viable code to complete a requirement was worth exploring. Especially when this snippet could be used in a LOT of common business processes such as:

  • All employees agreeing to a policy like Bill 168
  • All managers performing an annual review of their employees
    (succession planning, performance evaluations, etc.)
  • Sales leads forecasting demand pipeline

The Goal

A client wanted to use Gravity Forms / Gravity Flow to have all of their managers perform reviews of each employee they manage. I saw 3 different approaches to solve that requirement:


There are multiple ways to generate bulk Gravity Forms entries which trigger Gravity Flow workflows.  You may benefit from using a bash script looping Gravity Flow CLI commands OR a function hooked to gform_pre_submission that enables Gravity Forms Entry Importer from Gravity View to map hidden email fields into Gravity Flow user / assignee fields.

Solution Concept 1           

Manager submits a form for each employee. They must select name from a drop-down list

  • Pro(s): Low development complexity
  • Con(s): Manager has no ability to track which employees they have reviewed manually

Solution Concept 2

Bulk create entries which have workflow step assigned to manager with employee data pre-populated

  • Pro(s): Improved manager user experience; system tracks which reviews are yet to be complete
  • Con(s): Development may be form-specific. HR resource has to create all the entries.

Solution Concept 3

One form that enables client to define criteria for bulk submission of another (selected) form. Entries are automatically created with workflow step assigned to manager with employee data pre-populated.

  • Pro(s): To all end-users, it’s magical experience. Highly re-usable for future scenarios
  • Con(s): Not insignificant development effort

While the material outcome of requesting someone fill out a form is identical to a scenario that asks them to review a pre-populated form and add their comments into appropriate fields, the user experience, time-to-complete task and data quality increase measurably in the latter case. Especially when that person is being asked to submit / review multiple entries.

So really only the latter two potential solutions I came up with were worth further consideration.  While the third option looks the most appealing in the long-term, it would also take the most amount of time to implement which wasn’t an option due to project time constraints. It is also highly probable that an implementation of #2 could be re-used in a future implementation of #3.

Implementation Options

How best to generate entries for specific managers to perform a workflow?

  1. Gravity Forms Entry Importer from Gravity View
  2. Gravity Forms CLI
  3. Gravity Forms API

I’ve had good experience with the Gravity Forms API but feedback from Steven Henty confirmed that that route may have performance considerations. Namely that “[in order to] generate a lot of entries then you’ll need to create them in batches of about 150 to avoid timeouts.” For those who do go this route, Pippen has written an excellent primer on batch processing for big data that is an essential piece of reading.

Implementation 1 – Bulk Gravity Workflow Creation via Gravity View Import Entries

When I wrote the first draft of this post I was going to suggest that while the demo video for the CLI makes a VERY compelling argument, I did not select it because that route closes off business users (who do not have command line access to server) from being able to directly generate entries. Unfortunately, current version conflicts between Gravity View Importer and other Gravity add-ons (Gravity Forms, Gravity Survey, Gravity Polls, Gravity Quiz) limited my success in going with that option. But I have documented it here for two reasons. One, based on past experience with their excellent support teams I know the GV team will resolve those issues in short order. Two, this function also ensures that one-off entry creation via the actual form can be used for the edge cases where client may have forgotten an entry to their .csv file.

Implementation 2 – Bulk Gravity Workflow Creation via Gravity CLI

Semi-succinctly, my use case was:

  • retrieve email addresses from a CSV file
  • Maps those values into fields to create Gravity Form entries
  • Lookup user ID based on those email addresses to map into Gravity Flow user field, assignee field, and basis for user meta data about the employee.

All of which can easily be achieved by a bash script looping on .csv for a series of WP-CLI commands before single call to the Gravity Forms CLI to create entry:

Execution takes 3 – 5 seconds per entry which is not exceptional, but certainly functional. Hat tip to some sage CLI tips from Shawn Hooper for a further optimization path on this:

I would normally recommend [things like] –skip-plugins and –skip-themes flags just to speed up the load time. But that won’t work in your case, as you need the Gravity Forms plugin working…I might be tempted to make a custom WP-CLI command that takes the reviewer and employee IDs and then does all the processing internally. It would avoid loading WordPress 4 extra times per iteration of the loop.

Shawn Hooper


The more one works with a plugin, platform or framework as a developer the faster they tend to be at producing quality results with it. Hopefully those results also come through less lines of code. That may come from conquering a learning curve, the amount of code / experience you can draw upon from past projects or that special other moment that comes as an awareness of “it just clicks” in your mind. What I really enjoy working with WordPress and the Gravity suite of plugins in particular is that there are so many functional (and efficient) ways to solve useful problems for yourself and clients.