Source – Gravity Forms
Gravity Forms is a premier forms plugin for WordPress. It is immensely popular and even more capable. This Extension allows you to use Gravity Forms form entries as a custom Source for SearchWP, making it possible to search Gravity Forms Entries with SearchWP!
Adding Gravity Forms Entries to SearchWP’s Index
Once SearchWP Source – Gravity Forms has been installed and activated, your Gravity Forms will appear in the Sources list for your SearchWP Engine.
Note: This custom Source can be used only with a Supplemental Engine.
Let’s say you were building a feature request area on your website and using Gravity Forms to collect entries.
You could utilize SearchWP to allow customers to first search existing entries before submitting their own, so they could join in up-voting the existing submission instead of creating a duplicate.
The first step would be to create a new Supplemental Engine that has our Feature Request Form as the Source:
With the form chosen (note that you can combine entries from multiple Gravity Forms into a single Engine if you’d like!) you can pick and choose which field(s) you’d like to consider for searching:
SearchWP allows you to search the entire Gravity Forms Entry as a whole, optionally consider any Notes that have been added, or choose exactly which field(s) should be considered when searching, each with its own relevancy weight!
Displaying Gravity Forms Entries as Results
The SearchWP Source – Gravity Forms Extension will make available Gravity Forms Entries as search results. This integrates as any Source would when working with a Supplemental Engine.
Unlike a native WordPress search that has The Loop which is an array of WP_Post
objects that WordPress’ API interacts with, the results set for a Supplemental Engine can be made up of any SearchWP Source object.
Gravity Forms does not have a proper object for Form Entries, each Entry is an array of key value pairs. As a convenience, SearchWP Source – Gravity Forms will return results in a wrapper object:
\SearchWP\Sources\GravityForms\Entry
This will help as you iterate over your results array:
Note: You can prevent SearchWP from wrapping results in the class with the following hook:
SearchWP Source – Gravity Forms allows you to make any Gravity Forms Entry searchable using SearchWP! You can make as many SearchWP Engines with as many Gravity Forms Sources as you’d like, each with their own configuration of Fields and/or Notes. Use SearchWP’s capable search algorithm to make your Gravity Forms Entries searchable!