Skip to content

Instantly share code, notes, and snippets.

@alexcasalboni
Created November 6, 2014 18:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexcasalboni/7b7aac3413dc74ee3c4e to your computer and use it in GitHub Desktop.
Save alexcasalboni/7b7aac3413dc74ee3c4e to your computer and use it in GitHub Desktop.
Protected channels (only moderators' posts)
(function($){
$(function(){
//on domready
muut(function(app){ //on forum load
//retrieve DOM element
var createInput = $('.m-form.m-create');
var only_admin_channels = ['Your Channel 1', 'Your Channel 2']; // list of channel-titles
var is_moderator = app.is_signed && app.user.is_admin;
//on load and update events
app.on('load update', function (_, e) {
//if channel page and not a moderator and protected channel
if(e.type == 'page' && !is_moderator && -1!==$.inArray(e.title, only_admin_channels)){
createInput.hide();
}else{
createInput.show(); //this won't collide with 'display: none !important'
}
});
});
});
})(window.jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment