How to conditionally hide a link

matthes
Community Novice
1
683

We’re looking at conditionally hiding a link on our canvas course page based on a user id. I have already programmed a mapping in our database so we know which canvas users are which in our own database, and can use this canvas id to conditionally hide it.  

By law, we have to offer the student a way to opt out of an eBook offering and if they do we need to hide the LTI eBook link from them or disable it for them on their page.

Does Canvas hide or use the users ID anywhere on the page in an HTML block, such as the ID, or a field that will always contain the logged in users ID, or is there some generic endpoint available that I can make an ajax call to, outside the scope of the API authorization cycle, in order to obtain the current users ID?

 If it’s somewhere in the page I can grab the HTML and parse it out to get the ID that way. It would be when users are already into a specific course.

 All of our users should also have the SIS or integration ID, so we could use those as well. This ajax call would be to our own system to verify whether or not the link would then be hidden for the specific logged in user. 

I’d be OK using the API authorization flow, however in order to obtain the correct user access token and refresh tokens we need to know who they are.

Tags (1)
1 Comment