Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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