Add New Plugin Issue

User
Config::define('DISALLOW_FILE_MODS', false);
Not showing add new plugin option
Assistant
The issue is likely related to other WordPress configurations or permissions, despite setting `DISALLOW_FILE_MODS` to `false` in your `config/application.php` file. Here's a checklist to troubleshoot and resolve the issue:

### 1. **Verify WordPress Permissions**
Ensure the file and folder permissions are correctly set in your WordPress installation.

– Folders: `755`
– Files: `644`
– Ownership: The `www-data` user (or the web server user) should own the files and folders.

Run the following commands to fix ownership and permissions if needed:

sudo chown -R www-data:www-data /path/to/wordpress
sudo find /path/to/wordpress -type d -exec chmod 755 {} ;
sudo find /path/to/wordpress -type f -exec chmod 644 {} ;

### 2. **Confirm Other Configurations**
Make sure no other constants in `config/application.php` are overriding `DISALLOW_FILE_MODS`. For example:

– Check for `DISALLOW_FILE_EDIT`, which disables plugin and theme editing in the admin panel.
– Ensure there is no additional `define('DISALLOW_FILE_MODS', true);` statement elsewhere.

### 3. **User Role Permissions**
The "Add New Plugin" option is only visible for users with the **Administrator** role. If your user account doesn't have sufficient privileges:

1. Verify the user role in the database:
– Check the `wp_usermeta` table for your user.
– Look for the `wp_capabilities` meta key.
– Ensure it has `a:1:{s:13:"administrator";b:1;}`.

2. Update the user role if necessary:

wp_update_user(array(
       'ID' => $user_id,
       'role' => 'administrator'
   ));

### 4. **Verify Plugin Management Status**
Some plugins like **Wordfence**, **WP Super Cache**, or **UsersWP** (which you’re using) might block file modifications for security purposes.

– Disable such plugins temporarily to test if they’re causing the issue.

### 5. **Multisite Installations**
If your WordPress setup is a **Multisite Network**, the "Add New Plugin" option is only available in the Network Admin dashboard, not on individual site dashboards.

1. Go to **My Sites > Network Admin > Plugins**.
2. Check if the "Add New Plugin" option is visible there.

### 6. **Debugging and Logging**
Enable debugging to check for potential errors:

define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false);

Look for errors in the `wp-content/debug.log` file related to plugin management.

### 7. **Reinstall WordPress Core**
If none of the above works, try reinstalling the WordPress core files via the dashboard or manually upload fresh WordPress files (except for `wp-config.php` and the `wp-content` folder).

Let me know which of these steps helps, or if further assistance is needed!

User
chwon www-data:www-data
Assistant
The correct command is `chown` (not `chwon`). Here's how to use it:

To change the ownership of your WordPress files and folders to `www-data` (the web server user), run the following commands:

sudo chown -R www-data:www-data /path/to/wordpress

### Explanation:
– `sudo`: Runs the command with superuser privileges.
– `chown`: Changes the ownership of files and directories.
– `-R`: Applies changes recursively to all files and subdirectories.
– `www-data:www-data`: Sets the user and group ownership to `www-data`.
– `/path/to/wordpress`: Replace this with the actual path to your WordPress installation.

After running the command, verify the ownership:

ls -la /path/to/wordpress

This will show the file and directory permissions and ownership. Make sure all files and folders are owned by `www-data`.

Leave a Comment

Your email address will not be published. Required fields are marked *