How to create a custom listing contact form using Gravity Forms

Gravity Forms is a fantastic plugin for creating forms with WordPress especially if you don't want to use the default comment system with Easy Property Listings and prefer a custom form.

Create a custom form in Gravity Forms

Custom Listing Contact Form

Add hidden fields for the Listing title and URL

Add hidden fields

Populate your hidden fields with listing URL and title

Click the advanced tab of your hidden field and in the default value select Embed Post/Page title. The actual value is {embed_post:post_title}

Embed listing Title in Gravity Form

Repeat for the Listing URL and select Embed URL. That value is {embed_url}

Embed listing URL in Gravity Form

How to automatically insert that form into your listings

Now that you have a GravityForm ready to use and add to your listings.

First you need to get the shortcode for that form and the easiest way is using the Add Form button when editing a post/page.

Get gravity form shortcode

Copy your shortcode and replace it in the code below and insert into your theme functions file.

function my_epl_gravity_form_listing_contact() {
	echo do_shortcode( '[YOUR_GRAVITY_FORM_SHORTCODE]' );
}
add_action( 'epl_single_extensions' , 'my_epl_gravity_form_listing_contact' , 20 );

This function will output your form on the page provided that you haven't created a custom template and removed this hook

<?php do_action( 'epl_single_extensions' ); ?>

Form output on listing.

I've turned off the title but you can add it when setting the Gravity Form shortcode settings.

Contact Form Gravity Forms-1

Successful entry showing listing title and URL

Contact Entry in Gravity Forms

You can create some very fancy features using GravityForms and the conditional logic options.