0

Is there a way to check if some requirements are matched before adding new instance of custom post type to database? Like custom policies for adding new posts etc?

What I want to do is to build two custom types: "Event" and "Suggestion" connected by one-to-many relationship (by Pods Framework). I want to allow admins create Events and users create Suggestions. Suggestion for specific Event can be add if admin set Post Status of this Event as "Open for suggestions". When status is changed to "Closed for suggestions", there is no way to add new Suggestion related to this Event.

Is there any way too hook to some event before inserting post, that will check matching conditions and depending on result add or not post to database?

  • Yes, actually, there is a way to do this. Have you even tried? If so what have you tried? – Will the Web Mechanic Jun 20 '14 at 13:30
  • What you mean if I tried? I was looking for solution in Codex, here and by Google. But I didn't find anything helpful. – user54339 Jun 20 '14 at 13:50
  • For the conditions see WordPress Conditional Tags : codex.wordpress.org/Conditional_Tags For the events / hooks see these pages : codex.wordpress.org/Plugin_API/Filter_Reference codex.wordpress.org/Plugin_API/Action_Reference – Vinod Dalvi Jun 20 '14 at 14:45
  • I'm sorry if I am not clear enough. What I want to achieve is: 1. User is submitting new instance of Suggestion (one of meta fields of this Suggestion is referring to Event); 2. Hook for adding Suggestion is triggered, checking if referenced Event has status "Open"; 3. If not, inserting this Suggestion is canceled. My problem is what hook to use that will be triggered before inserting post and how to cancel this insertion. – user54339 Jun 20 '14 at 14:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.