Know How To Set Constant FS_Method?

Posted on

You might encounter a prompt from WordPress requesting your FTP credentials when attempting to install or update a plugin like Rank Math.

This occurs because your website’s file system is configured in a way that prevents direct modifications from the WordPress dashboard.

installing plugin

Within the WordPress plugins section, you can provide your FTP credentials and click “Proceed.”

WordPress will then start the installation. This prompt may also appear when updating plugins.

Alternatively, if you lack FTP access, you can use a direct method.

This article will guide you on how to modify the FS_METHOD constant to eliminate this prompt during Rank Math installation/updates.

First, let’s define what the FS_METHOD is.

What is FS_Method?

FS_METHOD is a WordPress constant that dictates how WordPress should write to the file system.

WordPress initially attempts to use the “direct” method, which writes files directly. This is the most efficient approach.

However, if your server doesn’t allow direct writes, WordPress automatically switches to the FTP method.

The FS_METHOD constant accepts the following values which dictate the method WordPress should use:

  1. direct
  2. ssh2
  3. ftpext
  4. ftpsocket

What is the impact of changing the FS_METHOD on my server?

Changing the FS_METHOD constant will not negatively affect your server. However, if you change the constant to something other than “direct,” WordPress will require FTP credentials to function properly.

Steps to Set the FS_METHOD:

Follow these steps to set the FS_METHOD:

Open wp-config.php File

Begin by opening the wp-config.php file. This file is located in your website’s root directory. You can access this file using FTP or your cPanel File Manager.

Add/Update FS_METHOD

In the wp-config.php file, check if FS_METHOD is already configured. If it’s not defined, add the following code:

If the constant is defined, you can update the FS_METHOD to ‘direct’, as seen below.

define( 'FS_METHOD', 'direct' );

Save/Upload the File

Finally, save the updated file (for cPanel File Manager) or upload it (for FTP) to implement the changes on your website.

Note: If your access to the wp-config.php file is restricted, please contact your web hosting provider to add the FS_METHOD.

There you have it—a step-by-step guide on adjusting the FS_METHOD constant. We hope you found this guide helpful.

Leave a Reply

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