I have a question about how to stop processing a post when a plugin(server side) finds errors on custom fields. Basically I developed a plugin which adds and process some custom fields in the edit post panel. When i click on publish/update button i'd like to stop the process of updating or saving the post...in fact the plugin can stop the process of storing data from the custom fields when occurres errors but even with errors, posts can be published or updated anyway. How can I handle this situation? Thank you all!
welcome to WordPress Answers. I'm afraid there isn't a (server-side) way of preventing posts being submitted.
The hook that is fired when a post is saved,
However, you can always retrieve the custom field values, validate them and then delete any invalid fields
(Keep in mind that you'll only want to delete custom fields with keys that your plug-in deals with. Users will not be impressed if they can't save their own custom field data because your plug-in thinks its invalid. On a related note, you should prefix your custom field keys with a prefix unique to your plugin)
Anyway, do to the above... (note: this is untested)
A few words of warning.
Finally if you wish to change the post status back to draft if you find invalid data, you may wish to look at my answer to this question.