• Resolved ilan76

    (@ilan76)


    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 1 year, 6 months ago by ilan76.
Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Support Kris – WPMU DEV Support

    (@wpmudevsupport13)

    Hi @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

    (@ilan76)

    Hi Kris @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 Williams – WPMU DEV Support

    (@wpmudev-support8)

    Hi @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

    (@ilan76)

    Hi Adam @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

    (@wpmudev-support7)

    Hi @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)

    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

    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

    (@wpmudev-support2)

    Hello @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.