Make a custom function available to block administrator settings

Re: Make a custom function available to block administrator settings

by Tim Hunt -
Number of replies: 0
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

settings.php files are include()ed twice on some pages, so if you try to define a function of class there, it breaks, as you found.

The solution is to define these things in a separate file (typically called settingslib.php) and then require_once() settingslib.php from settings.php.