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

I have a website that I am working on. I created an html form and put in some code that will take the form data and create a new wordpress post. It will post the information to a specific category. All is working.

Now I want to know what I can do to protect the data being entered? Should I use php and write pregmatch statements for every input? I have 7 different inputs on my form. I was thinking that wordpress would already have some functions that I could use to validate the data to make sure someone isn't trying any bad things with my form. The users who will fill out this form will not be registered or logged in.

share|improve this question
up vote 0 down vote accepted

Take a look at WordPress codex Data Validation entry, it covers most of the validation functions that come built-in with WordPress which you can use to validate your form submission.

share|improve this answer

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.