Skip to content

Instantly share code, notes, and snippets.

@ericmerrill
Last active November 22, 2024 19:32
Show Gist options
  • Select an option

  • Save ericmerrill/d2b0f3573c6439ced621fa2edfcc6d09 to your computer and use it in GitHub Desktop.

Select an option

Save ericmerrill/d2b0f3573c6439ced621fa2edfcc6d09 to your computer and use it in GitHub Desktop.
How to disable Moodle notifications in a CLI script
<?php
// Will disable all message providers, and set noemailever to true.
// Onle effects currently running script/page, and has no longer term ramifications.
$providers = $DB->get_records('message_providers');
$newsetting = [];
foreach ($providers as $provider) {
$newsetting[$provider->component.'_'.$provider->name.'_disable'] = 1;
}
if (isset($CFG->forced_plugin_settings['message'])) {
$CFG->forced_plugin_settings['message'] =& $newsetting;
} else {
$CFG->forced_plugin_settings['message'] = $newsetting;
}
$CFG->noemailever = true;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment