The Instructure Community will enter a read-only state on November 22, 2025 as we prepare to migrate to our new Community platform in early December. Read our blog post for more info about this change.
We used the following code snippets to hide the Delete Course and Cross-listing buttons from faculty. However, the code also hides the buttons from system admins. We would like the buttons to show for systems admins and not faculty. Any thoughts on how we might accomplish this?
#right-side .crosslist_link {
display: none;
}
a.btn.button-sidebar-wide.delete_course_link {
display: none !important;
}
Thanks for any advice you can provide.
I can't help with the coding, but I can say that our CSM was able to apply to do this for our Institution, we didn't have to do it ourselves.
You could accomplish something like this with Javascript, using Canvas's ENV variable:
var hideDelete = true;
for (role in ENV.current_user_roles) {
if (ENV.current_user_roles[role] === 'admin') {
hideDelete = false;
}
}
if (hideDelete) {
$('.delete_course_link').hide();
}
(The above can be improved upon--for example, first checking to see if the delete button exists on the page before checking the user's admin status.)
What a fabulous community!!!.
Thank you. We will give it a try.
Will,
The only way I can find to accomplish this without removing modifying their permissions is using JavaScript. Below is something quick i whipped up. This should do what you are looking for but I would definitely do some testing in your test environment before adding to live to ensure it works for your institution.
$(document).ready(function () {
var urlFifthLoc = document.URL.split('/')[5];
var isTeacher = false;
//Checks to see if user is a teacher
var roles = ENV['current_user_roles'];
var arrayLength = roles.length;
for (var i = 0; i < arrayLength; i++) {
if(roles[i] === 'teacher'){
isTeacher = true;
}
}
if(isTeacher === true)
{
if( urlFifthLoc === 'settings'){
var el = document.getElementsByClassName("btn button-sidebar-wide delete_course_link");
if (el.length > 0) {
el[0].style.display = "none";
}
}
if( urlFifthLoc === 'sections'){
var el = document.getElementsByClassName("btn button-sidebar-wide crosslist_link");
if (el.length > 0) {
el[0].style.display = "none";
}
}
}
});
Thank you so much for the help. We will give it a try. ![]()
Sorry for the delayed reply. We appreciate the support.
Can you also post the appropriate code snippet for hiding the moderate tool option in Assignments?
We have disabled the tool in the permissions so staff cannot use it, but it still appears as a selectable option when creating an assignment.
Thanks
We are giving the Canvas Admins area a little bit of love (especially questions that are really, really old) and just want to check in with you. This will also bring this question new attention.
Were you able to find an answer to your question? I am going to go ahead and mark this question as answered because there hasn't been any more activity in a while so I assume that you have the information that you need. If you still have a question about this or if you have information that you would like to share with the community, by all means, please do come back and leave a comment. Also, if this question has been answered by one of the previous replies, please feel free to mark that answer as correct.
Robbie
Community helpTo interact with Panda Bot, our automated chatbot, you need to sign up or log in:
Sign inTo interact with Panda Bot, our automated chatbot, you need to sign up or log in:
Sign in
This discussion post is outdated and has been archived. Please use the Community question forums and official documentation for the most current and accurate information.