views:

27

answers:

1

Hi

I would like to know how can i add a filter when i publish a wordpress post.

and if the has satisfied some conditions stated inside the filter it will continue to publish the post if not, it will abort from publishing the post and prompting the user that some conditions were not met?

Edit

Lets just say that the process inside would just return a true or false result.

@shelby Maybe to not completly abort but instead change the status to save as draft?

Thanks

A: 

You can hook 'transition_post_status', though I'm having trouble finding out what you'd do inside (or with the return value of) that hook to prevent publishing. Hooking 'publish_post' appears to happen later in the lifetime, so I'm not sure if you can prevent publishing at that point, though you have full access to the post and post ID, so I suppose in the worst case you could always revert the post's state in a function that you wire up to that event.

Harper Shelby