0

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.

1 Answer 1

1

The callback receives 5 params, so your code should read:

add_action( 'civicrm_validateForm', 'validate_org_form', 10, 5 );

BTW it's syntactically preferable to use add_action since there's nothing returned by the function as there is with add_filter.

1
  • Schoolboy error - thanks for responding! Commented Sep 20, 2022 at 14:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.