I am using wordpress 3.4 (the last before 3.5) and I have declared a post status type, and a custom user role called agent. It is for a custom post type, property.
register_post_status( 'purchased', array(
'label' => _x( 'Purchased', 'post' ),
'public' => false,
'exclude_from_search' => true,
'show_in_admin_all_list' => true,
'show_in_admin_status_list' => true,
'label_count' => _n_noop( 'Purchased <span class="count">(%s)</span>', 'Purchased <span class="count">(%s)</span>' ),
) );
My problem is that I don't want to show publicly those, (thus public=false
) but when I try to preview them with my user (in admin) it says:
You do not have permission to preview drafts.
EDIT 1
My code for preview is this:
$nonce = wp_create_nonce('post_preview_' . $post->ID);
$url = esc_url(add_query_arg(array( 'preview' => 'true', 'preview_id' => $post->ID, 'preview_nonce' => $nonce), get_permalink($post->ID)));
$previewUrl = "<a href=\"" . $url . "\" class=\"btn btn-info btn-mini\" target=\"wp-preview\" title=\"" . esc_attr(sprintf(__('Preview %s'), get_the_title())) . "\" rel=\"permalink\">" . __('Preview') . "</a>";
Kudos to Jesse for noticing the error, but, now when I go to the preview link i get a 404 error (not found). With public = true
this doesn't happen but it falls back to DO NOT SHOW category.
$nonce = wp_create_nonce('post_preview_' . $page->ID); $url = esc_url(add_query_arg(array( 'preview' => 'true', 'preview_id' => $id, 'preview_nonce' => $nonce ), get_permalink($page->ID)));
and linked the $url in an <a>..</a> (note$page
refers to the post type object)'preview_id' => $id
andget_permalink($page->ID)
, can you see the difference?