[wp-hackers] Is it possible to validate form data added in the add_meta_box

Glenn Ansley glenn at glennansley.com
Wed Apr 16 03:56:40 GMT 2008

I'm using the add_meta_box hook to create custom fields on the write post
and write page forms. The fields are inserting as expected into the DB
through publish_post, etc, but I was wondering if there was anyway to do
server-side validation of the data entered into my forms.

For example, if I have a "Number Field", is there a hook called before or in
conjunction with edit_post, save_post, and publish_post that would allow me
to run a PHP function to make sure the data was numeric in nature, and if
not, stop the form from being processed and return the page with an error
message? I realize that I can definitely validate in the publish_post, etc
hooks, but my problem is how to notify the user if it fails to validate.

I couldn't find any documentation or even discussion about this. If it
exists, could someone point me in the correct direction?


More information about the wp-hackers mailing list