5

Is there any way to disable the installation/updating of plugins in Wordpress?

I am deploying by Github, and therefore changes on server, does not replicate on my development environment.

I need to disable this, and make all updates and installations on my local Git repository, and THEN push to production, with the changes.

  • This means that the client can't add plugins themselves which can sometimes be undesirable. If you did want clients to be able to do this, but still sync between stages you could instead exclude plugins from the GIT repo and rsync the plugins folder, extra easy when done with Capistrano - at least that's how we do it. Just another option to consider. – Edd Smith Jun 15 '15 at 20:12
  • It's not for a client, I do full service on the site! - I'll take a look at Capistrano - Thanks – Frederik Spang Jun 15 '15 at 20:42
7

Set the constant DISALLOW_FILE_MODS to TRUE in your wp-config.php:

const DISALLOW_FILE_MODS = TRUE;

See the Codex for background information:

Setting this constant also disables the Plugin and Theme editor (i.e. you don't need to set DISALLOW_FILE_MODS and DISALLOW_FILE_EDIT, as on its own DISALLOW_FILE_MODS will have the same effect).

It will also prevent installing or uninstalling plugins, themes and updating the WordPress core.

This will not affect the Git deployment.

  • This is only for editing, right? How about actually installing/uninstalling plugins from the Plugin page? – Frederik Spang Jun 15 '15 at 20:43
  • 1
    @FrederikSpang This prevents everything. See my update. – fuxia Jun 15 '15 at 20:44
  • 1
    This may just be preference of core, but all the constants in wp-config.php are set using define() instead of const, probably because of the global use of them. define( 'DISALLOW_FILE_MODS', true ); matches the rest of the config file structure. – Morgan Estes Jun 15 '15 at 21:20
  • 2
    @morganestes The difference is that define() can evaluate expressions, while const cannot (and requires PHP 5.3). Not needed here. Use const for simple definitions, it is easier to read and to write. – fuxia Jun 15 '15 at 21:22
  • @toscho Thanks for the info. I always wondered why there were two different ways and never knew when to use one over the other. – Morgan Estes Jun 15 '15 at 21:23
0

There are quite a few related bits you can tinker with, but the one most comprehensive setting for version controlled stack is define( 'DISALLOW_FILE_MODS', true );. It will disable anything related to changing code files, core or extensions either.

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.