problem in functions.php
-
Hi.
i am using your plugin to block users from outside my country (Iran) submitting forms in my site.
I am using IP2Location Tags & Gravity Forms.
so here is my functions.php file:<?php // Adding IP2Location DB for IP Geo Block function my_ip2location_path( $path ) { return WP_CONTENT_DIR . '/ip2location-tags/IP2LOCATION-LITE-DB5.BIN'; } add_filter( 'ip-geo-block-ip2location-path', 'my_ip2location_path' ); // Set $validate to passed only if country is Iran (ir) function my_whitelist( $validate ) { $whitelist = array( 'ir', ); $validate['result'] = 'blocked'; foreach ( $whitelist as $country ) { if ( strtoupper( $country ) === $validate['code'] ) { $validate['result'] = 'passed'; break; } } return $validate; } // Validate Gravity Forms only if country of users is Iran add_filter("gform_validation", "ip_validation", 10, 4); function ip_validation($validation_result){ if ($validate == "passed") { $validation_result["is_valid"] = true; } else{ $validation_result["is_valid"] = false; } return $validation_result; } add_filter('gform_validation_message', 'change_validation_message', 10, 2); function change_validation_message($message, $form) { return "<div class='validation_error'>You can't submit this form outside of Iran. Thank you</div>"; } ?>
but it doesn’t work.
when i do var_dump($validate); , it return NULL.
how should i fix it?thank you.
Viewing 8 replies - 1 through 8 (of 8 total)
Viewing 8 replies - 1 through 8 (of 8 total)
- The topic ‘problem in functions.php’ is closed to new replies.