cancel
Showing results for 
Search instead for 
Did you mean: 
xcotto
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.btn.button-sidebar-wide.delete_course_link').hide();

       $('a.btn.button-sidebar-wide.reset_course_content_button').hide();

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

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

I

'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?

onPage(/\/courses\/\d+\/users/

Then,.

hasAnyRole('admin', function (hasRole)

       $('a.btn.button-sidebar-wide.delete_course_link').show();

       $('a.btn.button-sidebar-wide.reset_course_content_button').show);

       $("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
aclement
Community Member

Federico,

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) {