WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Submitting a post comment without message leads to a white page with a clean WP error message "ERROR: please type a comment."

Is it possible to achieve the same thing for input fields from a custom form? For instance, I've got my own custom contact page template containing a number of input fields, some of them I want to make required. How to get the same WP error message when those haven't been filled?

share|improve this question
up vote 1 down vote accepted

I believe yo are looking for wp_die which will Kill WordPress execution and display HTML message with error message.

But the codex says:

It is not recommended to call this function very often and try to handle as many errors as possible silently.

share|improve this answer
Thanks a lot Bainternet. I think "very often" is too vague though, does calling it for missing fields in contact form fall into the "very often" category? – drake035 Feb 15 '13 at 11:40
not really IMHO – Bainternet Feb 15 '13 at 17:29

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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