Skip to content

Instantly share code, notes, and snippets.

@NateWr
Created May 7, 2019 13:53
Show Gist options
  • Save NateWr/2af249345fc4d31b673e43fc9338eb08 to your computer and use it in GitHub Desktop.
Save NateWr/2af249345fc4d31b673e43fc9338eb08 to your computer and use it in GitHub Desktop.
Block requests to change the publishingMode setting from anyone except the site admin.
<?php
/**
* Refuse requests to change the publishingMode setting from anyone
* except the site admin.
*/
HookRegistry::register('Context::validate', function($hookName, $args) {
$errors &= $args[0];
$props &=$args[2];
if (/* user is not an admin */) {
$errors['publishingMode'] = ['You can not modify this setting.'];
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment