The primary objective with FormSync is to simplify your workflow in managing forms built with form builder plugins for WordPress. In the early phases of development so far, the focus has been on the overall form scan and sync processes. As those have been refined, the process of syncing forms has involved some manual action: navigating to the FormSync admin page, and selecting which form to sync. While this is better than the normal process of exporting and importing, it’s still not achieving the goal of full automation. That will change in version 0.5.
To provide fully automated form syncing, FormSync will be introducing a REST API, built on the native WordPress REST API. To trigger automatic form syncs, you can configure your deployment process to make an HTTP POST request to the plugin’s endpoint, and send along an Authorization header. FormSync will then run a sync on all the forms that are pushed as JSON in the deployment.
To show you how simple it is to automatically deploy your forms, let’s take a look at how you can use BranchCI to trigger a sync. BranchCI is a continuous integration/deployment service created by Peter Suhm. It’s built with WordPress in mind, so a perfect solution for our use!
Assuming you’ve connected your Github account (or other provider) and set up your project, triggering a form sync is as easy as adding a step to your build pipeline. Name your step something like, “Sync Forms,” select “cURL” as your selected environment, and paste the following snippet into the Commands section.
curl -X POST 'http://mysite.com/wp-json/formsync/v1/sync' -H "Authorization: Bearer $FORMSYNC_API_KEY"
Just make sure to update http://mysite.com with your domain. Then, we’ll add the
FORMSYNC_API_KEY environment variable under our project’s Environment settings, like so…
Once you’ve configured this step, BranchCI will send a POST request to your website, telling FormSync to sync all the forms. Any form that was updated in the deployment will now be updated in the new environment!