I would like to check a posts status, in particular I want to know if a post is set to draft or is privately published.
I have the following code:
if ('draft' != get_post_status() || is_user_logged_in()) {
$this->render();
}
else {
wp_redirect( site_url('404') );
exit;
}
It checks to see if a posts status is not set to draft or it checks if they are logged in and then renders either the post or redirects to the 404 page.
For some reason privately published posts are visible to non logged in users and I am trying to fix this.