How can I check if the user has access to any particular article? I was looking at $user->authorise() method but it looks like it's only for core edit, edit own and some other permissions.

  • It's common for people who are new to the site to ask questions and then never accept an answer. As a result, their newer questions tend to be ignored. Reputation points are the currency of this site, and accepting an answer is like tipping a waiter/waitress :-) please valid my anwser if it was resolving your question – Pierre-André Vullioud Mar 13 '16 at 20:45
up vote 3 down vote accepted

You can see an exemple of this check in this file

modules/mod_articles_latest/helper.php

https://github.com/joomlagovbr/joomla-3.x/blob/master/modules/mod_articles_latest/helper.php

$authorised = JAccess::getAuthorisedViewLevels(JFactory::getUser()->get('id'));

if (in_array($item->access, $authorised))
{
    // We know that user has the privilege to view the article
    // do something here
}

Where $item is your article

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.