Thread Starter
Matt
(@syntax53)
Actually, what it looks like is happening is the plugin still works and still restricts the post from publishing, but your plugin fails to see that and still views the page; it’s just still in a draft state and you’re viewing a preview.
I added “if($post->post_status != ‘auto-draft’ && $post->post_status != ‘draft’) {” to the following code to at least check to make sure a post has been published–
function publish_view_redirect($location)
{
global $post;
if (isset($_POST['publishview'])) {
if($post->post_status != 'auto-draft' && $post->post_status != 'draft') {
$location = get_permalink($post->ID);
}
}
return $location;
}
add_filter('redirect_post_location', 'publish_view_redirect');
Thread Starter
Matt
(@syntax53)
edit: Looks like $post doesn’t get updated with the latest draft status. So I modified it to reget the post before checking:
function publish_view_redirect($location)
{
global $post;
if (isset($_POST['publishview'])) {
$updated_post = get_post($post->ID);
if($updated_post->post_status != 'auto-draft' && $updated_post->post_status != 'draft') {
$location = get_permalink($post->ID);
}
}
return $location;
}
add_filter('redirect_post_location', 'publish_view_redirect');
Hi Matt, I’ve added basic support for this in version 2.2