General developer forum

Check if user has access to activity by code

 
Picture of Mark Johnson
Re: Check if user has access to activity by code
Core developersParticularly helpful MoodlersPlugin developers

The cm_info class has a "uservisible" property, which should tell you whether or not the current user has access to that activity.

 
Average of ratings: -
Picture of nadav compedia
Re: Check if user has access to activity by code
 

Hi,

I am using this property to check if the user has access, but even though at the completion report (report/progress/index.php) I see the activity is marked as completed by the user, the uservisible property of cm_info is NULL.

 
Average of ratings: -
Picture of nadav compedia
Re: Check if user has access to activity by code
 

problem is solved using 

rebuild_course_cache()
is there another solution? because it seems inefficient
 
Average of ratings: -