Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Possible Duplicate:
don't publish custom post type post if a meta data field isn't valid

A custom post type is being developed in wordpress. It is needed that some fields should be made mandatory. Is there a method in Api using which posts fields could be made mandatory? Or it would need to be done using custom code?

Working:

I am making a custom post type for an Event. Now when creating a new Event it is mandatory that the user enters the date, otherwise it should not allow to save him the event.

share|improve this question

marked as duplicate by brasofilo, toscho Aug 14 '12 at 9:40

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
I was pretty sure there's a duplicate of this one, but can't seem to find it. Using an API Method is custom code. I suggest you to add details to your Question, what fields are you talking about? How's your CPT being developed? Otherwise, IMO, the Q is overly broad... –  brasofilo Jul 18 '12 at 17:44
    
made the question a little more informative. –  backTangent Jul 18 '12 at 18:00

1 Answer 1

agree that the question is broad. first thought is you could hook into pre_post_update and check for the presence of the fields you require. if they are there, save the post. if they are not there, then do not save, but generate an admin notice.

edit: based on comments, save_post is too late, so i've amended the answer to say pre_post_update

share|improve this answer
    
Almost correct accept save_post hook is fired after the post is already saved –  Bainternet Jul 18 '12 at 18:06
    
Try using pre_post_update –  Brian Fegter Jul 18 '12 at 18:38

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