Sometimes, WordPress may prompt you to enter your FTP credentials while attempting to install or update a plugin.
This happens because your website is configured to use a filesystem that restricts direct file modifications through the WordPress dashboard.
The plugin requires the Filesystem Method to be set to "direct" for updates to function correctly.
What is FS_Method?
Each web host has its own set of limitations regarding server configurations. When you attempt to install or update plugins, WordPress CMS first checks if it has the necessary write permissions for the relevant files on your server and then automatically determines the filesystem to use.
However, if WordPress detects an FTP method instead, you'll be prompted to enter FTP credentials. If you prefer not to use the FTP method, you can force WordPress to use the direct filesystem by defining the FS_METHOD constant in your wp-config.php file.
The FS_METHOD constant defines WordPress's filesystem method for reading, writing, modifying, or deleting files.
FS_METHOD can accept one of the following values:
- direct
- ssh2
- ftpext
- ftpsockets
Why Might I Need to Change FS_METHOD?
There are several reasons you may need to change the FS_METHOD constant:
1. Server Configuration Limitations: If your server doesn't permit direct file writes, you'll need to specify an alternative method for WordPress to function correctly. Your host might have disabled the Direct method for security reasons, in which case FTP or another method would be required.
2. Plugin or Theme Development: If you're developing a WordPress plugin or theme that requires writing to the filesystem, WordPress usually restricts this action by default. You can adjust the FS_METHOD constant to options like ssh2, ftpext, or ftpsockets to allow your plugin or theme to write to the filesystem.
How To Set Constant FS_Method?
1. Log into your cPanel or FTP account.
2. Go to the Files > File Manager.
3. Inside the public_html, look for the wp-config.php file.
4. In the wp-config.php file, verify if the FS_METHOD constant is defined. If it is not defined, locate the line that reads:
That's all, stop editing! Happy blogging. */
Add the following code just above this line:
define( 'FS_METHOD', 'direct' );
If the constant is already defined, you can update its value to "direct," as shown below.
5. Save the file (if using cPanel File Manager) or upload it (if using FTP) to apply the changes to your website.