o/ SO

So I'm working on a plugin, that i use together with all my themes, where i have added a little option page. From my option page i would like to be able to disable stuff like WP_DEBUG, DISALLOW_FILE_EDIT and so on.

But I'm not quite sure if its even possible to do so? i have been searching for some time now, and i seem unable to find actually information whether this is possible (and how if it is)


I understand what you are trying, to make changing the WP config settings more convenient but I do not think it is possible to change them from a plugin.

Constants like WP_DEBUG and DISALLOW_FILE_EDIT are defined in core files, specifically in
wp-config.php, according to the Codex and, looking over the source code of this file and related files, I could not find any hooks to affect their definition.

And, in PHP, once constants are set they can no longer be changed during execution. Their value cannot be changed and they cannot be unset. Attempting to redefine or unset a constant will result in an error.

Here is a small quote from the PHP manual on constants:

As the name suggests, that value cannot change during the execution of the script

If there are no hooks to affect the definition of these constants and if they cannot be unset, then I do not see a way around this. Editing the wp-config.php file seems to be the only way to change the settings.

  • Thank you, it was kinda also what i figured but - its good to hear from somebody else! – Mac Mar 28 '17 at 12:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.