Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_filter('gform_validation_9', 'validate_donation');
- function validate_donation($validation_result) {
- //if form has already failed validation, don't process donation
- if(!$validation_result["is_valid"]){
- return $validation_result;
- }
- // Make a call to process_payment function to process payment and check validity
- $is_valid = process_payment();
- // If the payment is valid don't do anything, return $validation_result
- if($is_valid){
- // Return the validation result
- return $validation_result;
- }
- else{
- // Fail the validation for the entire form
- $validation_result['is_valid'] = false;
- // Return the validation result
- return $validation_result;
- }
- }
- add_filter("gform_validation_message_9", "change_message", 10, 2);
- function change_message($message, $form){
- global $donate_error;
- if(!empty($donate_error)){
- //only display custom validation message if there was an error with the donation processing
- return '<div id="donate_error">' . "An error occurred while processing your submission.<br/>Please modify your information based on the error below and try again.<br/><br/>" . '<span>' . "Error: {$donate_error}" . '</span>' . '</div>';
- }
- else{
- //display default message when a standard form validation error occurs.
- return $message;
- }
- }
Add Comment
Please, Sign In to add comment