开发者

how to abort or continue to publish a wordpress post

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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜