After many hours of researching, I cannot find a viable solution to integrate wordpress and google sheets to the following end: I want to create a form with dynamic fields that ultimately pulls data from a google sheet.
The data is constantly changing and is updated by individual inputs in other applications, so updating manually on the back end of the forms editor each time is out of the question.
So far, I have played around using WPForms and tried exploring the use of google sheets api as well. It appears that the most common solution is to use php and pull data from the content of a page on WP itself. That seems overly complicated for what I thought would be a common enough operation.
Open to known options on how to do this including different WP plugins.
[ad_2]
Keep in mind – if you make dynamic content then request php calls to get new data each time a page is loaded, you’ll incur a large processing overhead on the server cpu. What you are asking seems reasonable, but it’s harder to control dynamic data loads. Other options: calling form fields from post data means you might be able to do something hacky there to give a unique/new post data to each new one required. then posts can be created with custom fields for filter the way you want.
There are a couple of plugins that can pull from Google sheets. It’s a very tough job because Google’s APIs change frequently.
I have one site that still works with the Inline Google Spreadsheet Viewer ) which is still in the free WP repository. But it hasn’t been updated for three years. If it works for you it’s a *very* good solution since, with some work, you can basically queries with Google’s SQL-like queries. (The site I used it on uses pretty basic features, which evidently still work.)
I think there are some other premium plugins out there that will also query Google Sheets — likely necessary since, as I mentioned, it requires frequent attention to keep up with changes.
If by “data is constantly changing” you mean minute-by-minute then @Admirable-Habit-9006 is right that your queries are going to be pretty resource intensive. I think Google itself only allows API calls of cached versions with maybe a 5-minute refresh rate.
If instead you mean “changes daily” then you might look into other plugins that can consume and process XML or JSON. Google sheets can be exported as XML and it looks like there’s at least one extension that might be able to do it automatically. Google might also have APIs for that.
It would still be a lot of work to extract and display it but at least it’s feasible. And depending on how often the data refreshes it might be less data-intensive (and more cache-able) than making direct calls to Google’s API.
You *might* be able to download that inline google sheets reader plugin I mentioned and poach code from it (at one time the author militantly pro open-source.) I think there might even be code in the plugin for consuming other data sources.
Final point: it looks like that plugin can also consume CSV files, and even check for changes. If so then if you could find a way to frequently download your Sheets data as CSV you still might be able to get it to work. I know some of the commercial plugins can do the same thing so…
Looks like an interesting project. Hope you find a solution.