How to prevent WordPress from asking FTP information when doing updates?

The story :

One of the great features of WordPress is that it allows you to automatically download, install and upgrade plugins or WordPress core files.

A common issue is that WordPress asks for your FTP information when it can’t access the files directly, which results in a page indicating  “To perform the requested action, connection information is required.“.

This is usually caused by PHP running as the apache user (mod_php or CGI) rather than the user that owns your WordPress files.

ftpinfo

How to get rid of that?

Go to your WordPress installation directory and go for editing wp-config.php file.

Then add the following lines at the end of the file :

define('FS_METHOD', 'direct');
//add ftp login details
define('FTP_HOST', 'ftp.yoursite.com');
define('FTP_USER', 'Your_FTP_Username');
define('FTP_PASS', 'Your_FTP_password');

Save wp-config.php file, and it’s done. Happy Updating!