Wordpress 3.8 – update plugins prompting for FTP Login

The Problem

After upgrading to WordPress 3.8, trying to update plugins fails with the prompt for FTP login credentials.

The error message reads:

“To perform the requested action, WordPress needs to access to your web server. Please enter your FTP credentials to proceed.?

The solution

After reading many pages about the issue everyone says it is down to security on the file system or the user who owns files on the file system not matching the user running the WordPress site.

So I attempted to edit an existing plugin by changing a version number from 1.3.0 to 1.3.1 and saving the plugin. This saved and the plugin UI updated with the new version number so this proved that security was not the issue.

In my wp-config.php file I have the following defined:

define ('FS_METHOD', 'direct');

This tells WordPress that I wish to force the “direct” method of plugin updates.

The problem is found in .\wp-admin\includes\file.php

The method in question that is causing all the problems is “get_filesystem_method”

I debugged through this method and it gets all the way to the bottom and $method = ‘direct’

The final line of this method is:

return apply_filters('filesystem_method', $method, $args);

I changed this to:

//return apply_filters('filesystem_method', $method, $args);
echo($method . '<br/>');
$method = apply_filters('filesystem_method', $method, $args);
echo($method . '<br/>');
return $method;

When you try to update a plugin you will see the “echo” statements printed out on-screen and it shows that $method is being changed from ‘direct’ to ‘ftpext’, by the apply filters method.

To fix the problem change the return statement of ‘get_filesystem_method’ as follows:

//return apply_filters('filesystem_method', $method, $args);
return $method;

Now you are forcing ‘get_filesystem_method’ to return ‘direct’, and when I attempt an update a plugin it works.

6 thoughts on “WordPress 3.8 – update plugins prompting for FTP Login

  1. I’m having the exact same issue. Plesk automatically installs the new 3.8 version. I tried your method above and it didn’t work for me. In the wp-config.php file this is what’s different from 3.7+

    if(is_admin()) {
    add_filter(‘filesystem_method’, create_function(‘$a’, ‘return “direct”;’ ));
    define( ‘FS_CHMOD_DIR’, 0751 );

    if(is_admin()) {
    add_filter(‘filesystem_method’, create_function(‘$a’, ‘return “ftpext”;’ ));
    define( ‘FS_CHMOD_DIR’, 0755 );

    I tried commenting that out but it reeked havoc on the database connection. I’ve tried changing permissions on the wp-content dir but that hasn’t worked either. What exactly did you do to get this solved???


  2. Sorry Ken, I re-read my post and the solution was a little unclear, I have edited to hopefully be clearer. In short you need to edit:


    and change the last line of the method, ‘get_filesystem_method’ to;

    ‘return $method’.

    This fixed the issue for me as I obviusly don’t have security problems.
    It may cause more problems elsewhere as I don’t fully understand what the “apply_filters” call does, and I am commeting that line out!

    For me, so far so good.

  3. Thanks ever so much for posting your fix. I had temporarily worked around the problem by changing the two wp-config.php references to FS_CHMOD_DIR from 751 and 755 to 775. It was a horrible solution as clients would have still had to deal with the FTP uploader.

    If I run into any issues I’ll post them but I can’t imagine there will be any. Any ideas why this is something just affecting Plesk installs of WordPress? I seem to remember something about WordPress defaulting back to the FTP uploader when it detected issues in the ownership of the directories. A frustration-driven recursive chmod 777 didn’t fix the problem (still requested FTP access) so perhaps it is something to do with this?

  4. after correctly chmodding my files and adding in the FS_METHOD, I was able to bypass the FTP prompt.

    I looked in file.php and did not see what you described there. The issue might have been resolved in that file but still requires you do define FS_METHOD.

    1. Hi James, I recently upgraded to wordpress 3.8.1 and when I upgraded I had to “re-apply” the change as described above, and I can confirm that as of 3.8.1 the .\wp-admin\includes\file.php file still contains the “get_filesystem_method” function.

      Note: I am running wordpress on windows server, I assumed that the code base for linux vs IIS would be the same, but I could be mistaken?

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.