Title: After Adding PayPal
Last modified: May 21, 2023

---

# After Adding PayPal

 *  Resolved [ilan76](https://wordpress.org/support/users/ilan76/)
 * (@ilan76)
 * [3 years ago](https://wordpress.org/support/topic/after-adding-paypal/)
 * Hi,
 * I want to add a PayPal payment before submit but I see that it is actually replacing
   the submit button.
 * I’m using filter and action for the form:
 * add_filter(‘forminator_custom_form_submit_errors’….)
 * add_action( ‘forminator_form_after_save_entry’…)
 * How do I check the functions validation fields **BEFORE **submitting to paypal
   payment?
 * Does it behave the same as the submit button? I don’t want the users to submit
   a payment and then see submit/fields errors with my applied conditions, after
   a payment already made.
 * Thanks
    -  This topic was modified 3 years ago by [ilan76](https://wordpress.org/support/users/ilan76/).

Viewing 6 replies - 1 through 6 (of 6 total)

 *  [Kris – WPMU DEV Support](https://wordpress.org/support/users/wpmudevsupport13/)
 * (@wpmudevsupport13)
 * [3 years ago](https://wordpress.org/support/topic/after-adding-paypal/#post-16756500)
 * Hi [@ilan76](https://wordpress.org/support/users/ilan76/)
 * Using a PayPal button works the same as using a submit button when applying those
   filters and any custom validation will be performed before submitting a payment.
   Hope this helps.
 * Kind Regards,
   Kris
 *  Thread Starter [ilan76](https://wordpress.org/support/users/ilan76/)
 * (@ilan76)
 * [3 years ago](https://wordpress.org/support/topic/after-adding-paypal/#post-16756731)
 * Hi Kris [@wpmudevsupport13](https://wordpress.org/support/users/wpmudevsupport13/),
   thanks for your response.
 * How do I add my custom code for a field check with some external data api, **
   before **being able to pay via paypal?
 *  Plugin Support [Laura – WPMU DEV Support](https://wordpress.org/support/users/wpmudev-support8/)
 * (@wpmudev-support8)
 * [3 years ago](https://wordpress.org/support/topic/after-adding-paypal/#post-16757269)
 * Hi [@ilan76](https://wordpress.org/support/users/ilan76/)
 * I’m not quite sure what your custom code does and how it works but since you 
   already know how to use “forminator_form_after_save_entry” hook, you can use 
   instead the “forminator_form_before_save_entry” one.
 * The only difference here is that it only has a single argument, which is form
   ID. But it’s executed earlier, before form is saved so if you “terminate” code
   execution at this point – there’ll be no attempt to further submit the data.
 * If this is not what you are after, please explain a bit more what exactly your
   code is doing and what’s supposed outcome/result of it.
 * Kind regards,
    Adam
 *  Thread Starter [ilan76](https://wordpress.org/support/users/ilan76/)
 * (@ilan76)
 * [3 years ago](https://wordpress.org/support/topic/after-adding-paypal/#post-16757613)
 * Hi Adam [@wpmudev-support8](https://wordpress.org/support/users/wpmudev-support8/),
 * I’m using for example the add_filter(‘forminator_custom_form_submit_errors’) 
   for the entered field if it corresponds with another data (from external API)
   upon submit button – if not, it displays an error saying you need to enter something
   else and the form is not being submitted.
 * For the same situation, if I add the payment button, the payment is being processed/
   submitted and then displays the error message.
 * How can I handle to display the error before the payment is being processed?
 * I don’t want the user to pay before submission is successful…
 *  Plugin Support [Saurabh – WPMU DEV Support](https://wordpress.org/support/users/wpmudev-support7/)
 * (@wpmudev-support7)
 * [3 years ago](https://wordpress.org/support/topic/after-adding-paypal/#post-16768719)
 * Hi [@ilan76](https://wordpress.org/support/users/ilan76/)
 * Hope you are doing fine!
 * If you are using the **_forminator\_custom\_form\_submit\_errors _**, filter 
   then you can return the errors if a validation fails before the payment is processed.
 * Please find below an example of validating if some fields are empty or you can
   also add your own validation criteria (look at the comments in the code)
 *     ```wp-block-code
       add_filter( 'forminator_custom_form_submit_errors', 'wpmudev_limit_email_submission', 9999, 3 );
       function wpmudev_limit_email_submission( $submit_errors, $form_id, $field_data_array ) {
       	if ( $form_id != 6 ) { //Please change this number to the ID of your form 
       		return $submit_errors;
       	}
   
       	$submitted_data = wp_list_pluck( $field_data_array, 'value', 'name' );
   
       //  You can add your validation logic here
       // And then evaluate below based on the needed criteria
   
           if ( ! empty( $submitted_data['text-1']) ) {
               if ( $submitted_data['text-1'] != $expected_value_from_api ) {
                   $submit_errors[]['text-1'] = __( 'Value entered is not valid.', 'forminator' );
               }
           }
   
       	return $submit_errors;
       }
       ```
   
 * Hope this example helps. In case further assistance may be required, please help
   us sharing the form export and any custom code you have added to perform the 
   validation, so that we could review the existing settings.
 * Please take a look at the following doc on how to export a form:
   [https://wpmudev.com/docs/wpmu-dev-plugins/forminator/#import-export](https://wpmudev.com/docs/wpmu-dev-plugins/forminator/#import-export)
 * If you are concerned about any sensitive information in the form, then you can
   duplicate your form, remove any sensitive information, and then export it. You
   can share the export file via Google Drive, Dropbox or any cloud services in 
   the next reply.
 * Kind regards
 * Luis
 *  Plugin Support [Amin – WPMU DEV Support](https://wordpress.org/support/users/wpmudev-support2/)
 * (@wpmudev-support2)
 * [3 years ago](https://wordpress.org/support/topic/after-adding-paypal/#post-16791079)
 * Hello [@ilan76](https://wordpress.org/support/users/ilan76/) ,
 * We haven’t heard from you for over a week now, so it looks like you no longer
   need our assistance.
 * Feel free to re-open this ticket if needed.
 * Kind regards
    Kasia

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘After Adding PayPal’ is closed to new replies.

 * ![](https://ps.w.org/forminator/assets/icon-256x256.gif?rev=3443182)
 * [Forminator Forms – Contact Form, Payment Form & Custom Form Builder](https://wordpress.org/plugins/forminator/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/forminator/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/forminator/)
 * [Active Topics](https://wordpress.org/support/plugin/forminator/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/forminator/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/forminator/reviews/)

 * 6 replies
 * 5 participants
 * Last reply from: [Amin – WPMU DEV Support](https://wordpress.org/support/users/wpmudev-support2/)
 * Last activity: [3 years ago](https://wordpress.org/support/topic/after-adding-paypal/#post-16791079)
 * Status: resolved