SearchWP

Source – Gravity Forms

This Extension requires a Pro license

Current version: 0.0.2

Download available with active license

Table of Contents

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.

Screenshot of Gravity Forms setup

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:

Adding Gravity Form to SearchWP

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:

Adding Gravity Forms attributes to SearchWP

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:

<?php
$searchwp = new \SearchWP\Query( 'marketing', [
'engine' => 'gravity',
'fields' => 'all',
] );
foreach ( $searchwp->results as $result ) {
switch ( get_class( $result ) ) {
case 'SearchWP\Sources\GravityForms\Entry':
// NOTE: Gravity Forms Field values are keyed by the Field ID in the Form editor.
?>
<div class="result">
Form ID: <?php echo esc_html( $result->id ); ?><br>
Name: <?php echo esc_html( $result->{'1'} ); ?><br>
Email: <?php echo esc_html( $result->{'2'} ); ?><br>
Type: <?php echo esc_html( $result->{'3'} ); ?><br>
Feature: <?php echo esc_html( $result->{'4'} ); ?>
</div>
<?php
break;
default:
// Another Source was added to the SearchWP Engine.
print_r( $result );
}
}
view raw page.php hosted with ❤ by GitHub

Note: You can prevent SearchWP from wrapping results in the class with the following hook:

<?php
add_filter( 'searchwp\source\gravity_forms\entry\raw', '__return_true' );

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!

Changelog

0.0.2

  • [Fix] Error on activation
  • [Update] Updated updater

Want to make your search awesome right now?

More than 30,000 sites have chosen SearchWP!

You can utilize all of the content that’s gone unrecognized by native WordPress keyword search instantly with SearchWP.

Get SearchWP for just $99

  • Committed Support
    If you need help, support is fast, friendly, and here for you
  • Streamlined Setup
    Installation and setup that’s optimized for speed
  • Great Documentation
    Helpful, clear, and usable documentation is a priority

See what SearchWP customers have to say

  • “I’ve been using SearchWP for a few years now in several websites. This a great tool to enhance the accuracy of search results for your audience. In addition, their tech support is quick to respond and accurate. I strongly recommend it : )”

  • “We got SearchWP to allow searching through a large amount of PDF’s. We had some minor issues with a few old ones but essentially it just worked. Also, when we needed it, support has been quick and efficient.”

  • “I’m incredibly impressed by the simplicity, function and range of extensions that come with Search WP. Jonathan from support is prompt, friendly and most importantly – thorough. Highly recommended. Alex – Creative Director, Web Consultants”