function current_user_can_access_post_type($post_type, $context = 'display') { $post_type_object = get_post_type_object($post_type); if (!$post_type_object) { return false; } switch ($context) { case 'edit': return current_user_can($post_type_object->cap->edit_posts); case 'display': return $post_type_object->public || current_user_can($post_type_object->cap->read_private_posts); default: return false; } }