givewp
givewp copied to clipboard
give_checkout_error_checks hook runs twice
User Story
As a plugin developer, I want to do a custom validation and log the result.
Details
So we have a plugin that uses give_checkout_error_checks hook to validate a submission for spam detection/card testing attack. There are two cases: either validation fails or passes. In both cases, we log the activity. For some reason, hook runs twice in case of successful validation.
I removed our code and hooked a simple empty function add_action( 'give_checkout_error_checks', 'myplugin_givewp_pre_submission', 10, 1 ); to confirm the issue.
Expected Behavior
give_checkout_error_checks fires once.
Steps to Reproduce
- Enable debugging in WordPress
- Create a function that hooks to
give_checkout_error_checksin either a plugin's main file or in functions.phpadd_action( 'give_checkout_error_checks', 'myplugin_givewp_pre_submission', 10, 1 );
function myplugin_givewp_pre_submission($data) {
error_log( "Give fires..." ); // Write to debug.log
return $data;
}
- Check debug.log
Visuals
Additional Context
System Information
Details
- Give Version 2.22.1
- WP Version 6.0.2
Acceptance Criteria
- [ ]
give_checkout_error_checksfires once - [ ] Proposal of an alternative hook that fires once and able to set error using
give_set_errorto prevent submission/donation.