Conditional Fields

Show or Hide fields when conditions are met

GeoDirectory version 2.1.1.0 introduces a new, highly anticipated feature:

Conditional Logic for Custom Fields

This new feature allows you to create dependencies between fields, based on the conditions that you set.

Dependent fields will only be displayed and editable, if the input entered on the fields they depend on, matches the right conditions.

This feature is fundamental for business directory listings, with many custom fields making it possible to select preset fields only when these apply.

An easy-to-understand example is represented by custom fields for Car Classified Listings.

Presumably, you will have a field labeled “Brand”, where users will select their car manufacturers such as Ford, GMC, or Lamborghini.

And you will have a field labeled “Models“, where you select the model of the selected Brand of cars. If you select Ford, this field will display models such as C-Max, Fiesta, Focus, Fusion, Mustang, and so on.

If you select Lamborghini, this field will display models such as Huracan, Aventador, Gallardo, Murcielago, Diablo, and so on.

Car Classified Brand/Model conditional fields

To create this example, we added 3 custom fields to our setup. Brands, Ford Models, and Lamborghini Models.

On the Ford Models Field, we set the condition to show only when you select the Ford option in the Brands field.

On the Lamborghini Models Field, we set the condition to show only when you select the Lamborghini option in the Brands field.

It is as easy as that.

Another case in point would be for Real Estate Listings.

Let’s show a full tutorial, including how to set up the fields, using our WordPress Real Estate Theme.

Conditional Fields for Real Estate Listings

Our Real Estate listings demo includes a field labeled Property Type with options such as Houses, Apartments, and Land and another field asking for furnished/unfurnished status. Obviously, the second field never applies to Land properties.

In this case, we will add a Conditional Logic to the Furnishing select custom field by doing the following:

1. Open the Furnishing Select Field.

2. Click the “+ Conditional Field” link at the lower-left corner of the custom field options.

3 After clicking on it, a new set of options will appear.

4 For our example, we will need to set them as follows:

  1. ACTION = HIDE
  2. FIELD = Property Type
  3. CONDITION = equals to
  4. VALUE = Land

and save the custom field. Below you can see what this will look like.

After doing that, this is the result on the Front End:

Real Estate Conditional Fields

The same conditions can be added to other fields like the bedrooms or bathrooms fields, which are not needed if you are listing a piece of land.

You can also add multiple conditions if you need to do so.

The available options are:

  1. ACTION = SHOW/HIDE
  2. FIELD = All your fields
  3. CONDITION = empty, not empty, equals to, not equals, greater than, less then, contains.
  4. VALUE = accept text

And you can add as many as you wish for each field.

What are you going to build with GeoDirectory conditional custom fields?

Let us know in the comment down below…

Published by Paolo

Paolo Tajani is the co-founder and growth hacker of AyeCode LTD. With his business partner Stiofan, they are the makers of the GeoDirectory, UsersWP and Invoicing plugins for WordPress. Paolo developed his first WordPress website in 2008. In 2011 he met Stiofan O'Connor and together they started building and marketing successful themes and plugins for WordPress. Today their products are used by +100.000 active websites.

Loading...