Showing results for 
Search instead for 
Did you mean: 
Explorer III

Hide/Show Buttons for Certain user roles

Hi Team Smiley Happy

We have this JS to Hide the following buttons for Teacher Roles.

The problem is that I have the Account Admin role but when I created a manually courses I get enrolled automatically  as a Teacher role and the JS automatically hides me those buttons.

Actual Code:

if($.inArray('teacher,ENV['current_user_roles']) === 1) {



       $("a:contains('Conclude this Course')").hide();

       $("a:contains('Export Course Content')").hide();


've tried also the else if but but still hidden.

Is there something we can identify by the user enrollment role id and define it by that user role?



hasAnyRole('admin', function (hasRole)



       $("a:contains('Conclude this Course')").show();

       $("a:contains('Export Course Content')").show();

Any help will be appreciated

Smiley Happy

 @farbelaez ​

Tags (3)
0 Kudos
1 Reply
Community Member


Why not just add a check to see if the user is an admin to that first conditional?

if($.inArray('teacher,ENV['current_user_roles']) === 1 && $.inArray('admin,ENV['current_user_roles']) === -1) {