Accessing enrol attribute of $USER variable

Accessing enrol attribute of $USER variable

by Apoorv Jain -
Number of replies: 0

I am trying to displaying a block to any user who is a non-editing teacher (on any course). 

However when the moodle logins the user and redirects them to the dashboard then the enrol attribute of the $USER variable is not filled. 

Hence I am unable to browse through all the courses in which the user is registered. 

However once I refresh the page the values in enrol attribute fill in. 

I guess the problem is that moodle finished filling enrol variable later than displaying the blocks. Hence my code in blocks is not able to gather the values in enrol for the first time, however when we refresh the values get filled in and the block funtions well.

My question is how can I make the block function from the moment the user logins ? 

Average of ratings: -