Enable plugin installs without FTP with user from same group as Nginx/PHP-fpm

WordPress specifically checks that the fileowner of the files it creates are identical to the value returned by getmyuid.

Meaning that if it creates files using a different owner than the owner of the WordPress files themselves, it won’t use the “direct” mode.

Same group is not enough. The files WordPress writes must have the same ownership as the WordPress files themselves, or it won’t do it and will instead try other methods, such as FTP permissions. Meaning that the PHP process must be running as the same user that actually owns the WordPress files.

So if your PHP is running as “wordpress” but the files are owned by “user”, then you get the FTP stuff instead.

The test for this is in the get_filesystem_method() function.