Home > WordPress > WordPress 3.8 – update plugins prompting for FTP Login

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.

VN:F [1.9.22_1171]
Rating: 10.0/10 (1 vote cast)
WordPress 3.8 - update plugins prompting for FTP Login, 10.0 out of 10 based on 1 rating

Categories: WordPress Tags:
  1. Ken Brown
    December 21st, 2013 at 06:06 | #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???

    Thanks!!

    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  2. Ken Brown
    December 21st, 2013 at 06:21 | #2

    Just changed the setting so I can get follow-up comments by email…

    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  3. jcrawfor74
    December 21st, 2013 at 09:17 | #3

    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:

    ‘\wp-admin\includes\file.php’

    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.

    VN:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  4. December 23rd, 2013 at 23:05 | #4

    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?

    VA:F [1.9.22_1171]
    Rating: +1 (from 1 vote)
  5. James Wagoner
    April 1st, 2014 at 11:47 | #5

    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.

    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
    • jcrawfor74
      April 1st, 2014 at 13:54 | #6

      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?

      VN:F [1.9.22_1171]
      Rating: 0 (from 0 votes)
  1. No trackbacks yet.