I'm trying to implement some custom validation on a contribution form on WordPress.
I have this in my functions.php:
add_filter( 'civicrm_validateForm', 'validate_org_form', 10, 4 ); function validate_org_form($formName, &$fields, &$files, &$form, &$errors) {
But I get an error when the form submits:
Uncaught ArgumentCountError: Too few arguments to function validate_org_form
So it looks like this hook doesn't work the same for contribution forms as it does for others.
What I'm trying to do is check if an organisation already has a membership when a user is contribution on behalf of an organisation. I want to run an API call to check for memberships of the same type and fail the contribution with a message if any exist.