Require Unique Values Between Fields

Read the Walkthrough

Code

Filename: gw-require-unique-values-usage.php

<?php
/**
 * Gravity Wiz // Gravity Forms // Require Unique Values Between Fields
 * https://gravitywiz.com/gravity-forms-require-unique-values-for-different-fields/
 */

# Set Custom Validation Message

new GW_Require_Unique_Values( array(
	'form_id'            => 12,
	'field_ids'          => array( 14, 15 ),
	'validation_message' => 'My custom validation message!',
) );

# Use Case Senstive Comparison

new GW_Require_Unique_Values( array(
	'form_id'        => 12,
	'field_ids'      => array( 14, 15 ),
	'case_sensitive' => true,
) );

# Create Multiple Unique "Groups" on the Same Form

new GW_Require_Unique_Values( array(
	'form_id'   => 2,
	'field_ids' => array( 4, 5 ),
) );

new GW_Require_Unique_Values( array(
	'form_id'   => 2,
	'field_ids' => array( 7, 8 ),
) );

# Unique Field Compared to ALL Form Fields

new GW_Require_Unique_Values( array(
	'form_id'   => 2,
	'field_ids' => array( 7 ),
) );

Leave a Reply

Your email address will not be published. Required fields are marked *

  • Trouble installing this snippet? See our troubleshooting tips.
  • Need to include code? Create a gist and link to it in your comment.
  • Reporting a bug? Provide a URL where this issue can be recreated.

By commenting, I understand that I may receive emails related to Gravity Wiz and can unsubscribe at any time.