Jim Boy
Well-known member
I'm trying to deteremine whether posts can be viewed by guests, including when the post is in a private node:
The code I have is
but it returns a false positive when I use this in a restricted forum.
Any ideas what I am doing wrong? Is there a better way to go about this?
The code I have is
Code:
$postmodel=XenForo_Model::create('XenForo_Model_Post');
$post = $postmodel->getPostById($postid, array(
'join' => XenForo_Model_Post::FETCH_USER | XenForo_Model_Post::FETCH_USER_PROFILE | XenForo_Model_Post::FETCH_THREAD | XenForo_Model_Post::FETCH_FORUM
)
);
$userModel = XenForo_Model::create('XenForo_Model_User');
$errorPhraseKey="";
if (!empty($post) && $postmodel->canViewPost($post, $post, $post, $errorPhraseKey, null, $userModel->getVisitingGuestUser()))
{
return true;
}
return false;
Any ideas what I am doing wrong? Is there a better way to go about this?