If you're using CB 2.x you can use the below CB API to test if a user has access to a view access level as follows.
Current User:
Code:
$canAccess = Application::MyUser()->canViewAccessLevel( VIEW_ACCESS_LEVEL_ID_HERE );
Specific User:
Code:
$canAccess = Application::User( USER_ID_HERE )->canViewAccessLevel( VIEW_ACCESS_LEVEL_ID_HERE );
You can retrieve their view access levels with the below API as an array.
Current User:
Code:
$myViewAccessLevels = Application::MyUser()->getAuthorisedViewLevels();
Specific User:
Code:
$myViewAccessLevels = Application::User( USER_ID_HERE )->getAuthorisedViewLevels();
Both need to have the Application use statement at the top of your PHP file, which is as follows.
Code:
use CBLib\Application\Application;