Search code examples
wordpresspluginsupgradeadministrator

Can't upgrade WordPress or add new plugin while logged in as admin (using Sage theme)


I am logged into a WordPress site backend as an administrator. The theme was built using the Sage Starter Theme.

During development there was no issue with adding plugins or upgrading the core, but since moving to production, there is no "Add New" button for plugins and the upgrade message reads "WordPress 4.3 is available! Please notify the site administrator."

I tried manually changing the db_version field of the wp_options table to force a database upgrade. This didn't work.

I tried disabling all plugins and changing to the twentyten theme - this did not work.

Checked all permissions on the server - no joy.

How can I resolve this issue?


Solution

  • The latest Sage Starter theme uses a .env file to set up environments via the phpdotenv library. It lives in a directory above the public HTML web root of the WordPress installation.

    If you changed the line WP_ENV=development to WP_ENV=production in the .env file when the site went live, then it's likely this is the source of the issue.

    If you look at the actual configuration for the production environment in /config/environments/production.php, you see the following:

    define('DISALLOW_FILE_MODS', true); // this disables all file modifications including updates and update notifications
    

    This tells WordPress not to allow manual addition of plugins or allow core updates. You can simply edit this to be:

    define('DISALLOW_FILE_MODS', false); // allow file modifications including updates and update notifications
    

    After you've modified the core or added plugins, you can simply change it back if you don't want admins to have this power, but a better solution would be to install a capability manager plugin and define an admin role with slightly lower privileges.