User is adding a new email. Call to civicrm_pre detects a problem that requires that the update not happen. It hasn't actually happened by the time civicrm_post or post_save_civicrm_email is called. The update actually happens after post_save is called.

How do I abort the update?

1 Answer 1


While I suppose you could empty the $params array, it would be a bit clumsy. Meanwhile you'll need a way to notify the user in context, so something form-specific would be helpful.

Instead of using hook_civicrm_pre, you might consider using hook_civicrm_validateForm(). You'd be able to run the same checks, but in case the value is no good, you could send the user back to fix it.

  • I tried adding hook_civicrm_validateFom, but it never gets called. Is there something I must do to make sure it does get called?
    – Bob Jones
    Dec 6, 2015 at 19:32
  • Not sure where the problem is happening, but it should be getting called on any form you use. Try setting an error on a field you know is there by doing something like $errors['first_name'] = 'DEBUG TEST';
    – Andie Hunt
    Dec 7, 2015 at 5:29

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.