Gravity Forms Hooks & Filters
-
Upload
iamdangavin -
Category
Technology
-
view
7.557 -
download
1
Transcript of Gravity Forms Hooks & Filters
![Page 1: Gravity Forms Hooks & Filters](https://reader036.fdocuments.us/reader036/viewer/2022081821/55a3de721a28abd81f8b47f1/html5/thumbnails/1.jpg)
@iamdangavin | [email protected]
Hello
This is a presentation on the versatility of Gravity Forms in WordPress.
http://www.gravityhelp.com/documentation/page/Developer_Docs
![Page 2: Gravity Forms Hooks & Filters](https://reader036.fdocuments.us/reader036/viewer/2022081821/55a3de721a28abd81f8b47f1/html5/thumbnails/2.jpg)
@iamdangavin | [email protected]
Hello
Checking a table within our database and validation our form.
http://www.gravityhelp.com/documentation/page/Gform_validation
![Page 3: Gravity Forms Hooks & Filters](https://reader036.fdocuments.us/reader036/viewer/2022081821/55a3de721a28abd81f8b47f1/html5/thumbnails/3.jpg)
@iamdangavin | [email protected]
Hello
add_filter('gform_validation', 'code_validation');
function code_validation($validation_result){
// setting up to check against out database. global $wpdb;
$input = $_POST['input_5']; $code_check = $wpdb->get_results("SELECT code FROM code_check WHERE code =\"$input\"");
foreach($code_check as $row){ $code = $row->code; } //end foreach
if($code != $input){ // set the form validation to false $validation_result["is_valid"] = false; //finding Field with ID of 1 and marking it as failed validation foreach($validation_result["form"]["fields"] as &$field){ /NOTE: replace 5 with the field you would like to validate if($field["id"] == "5"){ $field["failed_validation"] = true; $field["validation_message"] = "Sorry, That code has either been used before or incorrect. Please try again!"; break; } //end if } //end foreach } //end ifreturn $validation_result; } //End function_exists
![Page 4: Gravity Forms Hooks & Filters](https://reader036.fdocuments.us/reader036/viewer/2022081821/55a3de721a28abd81f8b47f1/html5/thumbnails/4.jpg)
@iamdangavin | [email protected]
Hello
Client Portal & Email Author of page
http://www.gravityhelp.com/documentation/page/Gform_field_value_$parameter_name
![Page 5: Gravity Forms Hooks & Filters](https://reader036.fdocuments.us/reader036/viewer/2022081821/55a3de721a28abd81f8b47f1/html5/thumbnails/5.jpg)
Hello
@iamdangavin | [email protected]
gform_!eld_value_$parameter_name
Use this !lter to add a default value to the !eld speci!ed by $parameter_name.
add_filter('gform_field_value_current_client_ID', 'hidden_current_client_ID');
function hidden_current_client_ID($value){
global $curauth;
return $curauth->ID;}
gform_noti!cation_email
Use this !lter to dynamically change the TO email for admin noti!cation.
// Hook to send the author an email that a message has been sent to them// Update the 1 in the gform_notification_email to your form ID. If you would like this to be a global change, remove the _1.add_filter("gform_notification_email_1", "change_notification_email", 10, 2);function change_notification_email($email, $form){ // update the '5' to the ID of your field $email = $_POST['input_5']; return $email; }
![Page 6: Gravity Forms Hooks & Filters](https://reader036.fdocuments.us/reader036/viewer/2022081821/55a3de721a28abd81f8b47f1/html5/thumbnails/6.jpg)
@iamdangavin | [email protected]
Goodbye
• Gravity Forms Download
• Gravity Forms Documentation
• Gravity Forms + Custom Post Types Plugin
• Gravity Forms CSS
Resources & Plugins