Last active
November 22, 2024 19:32
-
-
Save ericmerrill/d2b0f3573c6439ced621fa2edfcc6d09 to your computer and use it in GitHub Desktop.
How to disable Moodle notifications in a CLI script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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