<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="bbPress/1.0.1" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>Gravity Support Forums Topic: Custom validation for is_duplicate</title>
		<link>https://legacy.forums.gravityhelp.com/topic/custom-validation-for-is_duplicate</link>
		<description>Gravity Support Forums Topic: Custom validation for is_duplicate</description>
		<language>en-US</language>
		<pubDate>Fri, 10 Apr 2026 05:41:03 +0000</pubDate>
		<generator>http://bbpress.org/?v=1.0.1</generator>
		<textInput>
			<title><![CDATA[Search]]></title>
			<description><![CDATA[Search all topics from these forums.]]></description>
			<name>q</name>
			<link>https://legacy.forums.gravityhelp.com/search.php</link>
		</textInput>
		<atom:link href="https://legacy.forums.gravityhelp.com/rss/topic/custom-validation-for-is_duplicate" rel="self" type="application/rss+xml" />

		<item>
			<title>adzyubchik on "Custom validation for is_duplicate"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/custom-validation-for-is_duplicate#post-37863</link>
			<pubDate>Thu, 13 Oct 2011 16:32:55 +0000</pubDate>
			<dc:creator>adzyubchik</dc:creator>
			<guid isPermaLink="false">37863@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Hello.&#60;/p&#62;
&#60;p&#62;I have a task. User enter in the form a key and address. I have to check the key of user. If the key is in database, we accept form submission only once. If the key is not in DB, we show error message &#34;unvalid key&#34;. Before running the form I will fill the entries database with the list of valid keys.&#60;/p&#62;
&#60;p&#62;I suppose it is good idea to use is_duplicate filter for checking the key, but I have no idea how to make the validation work in the way I want.&#60;/p&#62;
&#60;p&#62;Should be something like this:&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;add_action(&#38;#39;gform_is_duplicate_1&#38;#39;, &#38;#39;check_key&#38;#39;, 10, 4);
function check_key($count, $form_id, $field, $value) {
// If there is one entry of such a key, accept form submission and add one more entry with this key and address
//(would be great to update entry, instead of adding one more, but I guess GF doesn&#38;#39;t have such a functionality)
    if ( $count == 1  )  {
       add_filter(&#38;quot;gform_field_validation_1_2&#38;quot;, &#38;quot;custom_validation&#38;quot;, 10, 4);
       function custom_validation($result, $value, $form, $field) {
          $result[&#38;quot;is_valid&#38;quot;] = true;
       }
    }
    else {
         $error_message=&#38;quot;Invalid key!&#38;quot;;
    }
}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;Could you please help me with the code?
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
