Description
Get filesystem credentials from the user, to be passed to WP_Filesystem.
Usage
$creds = request_filesystem_credentials(
$form_post,
"", // type
false, // error
false, // context
null, // extra_fields
false // allow_relaxed_file_ownership
);
if ( false === $creds ) {
return;
}
Parameters
- $form_post
- (string) (required) The URL that the resulting form should be posted to. Most likely the URL should be created with wp_nonce_url().
- Default: None
- $type
- (string) (optional) The type of method to use for the WP_Filesystem. This is normally determined automatically, and so should remain a blank string. Useful for debugging only.
- Default: blank string
- $error
- (boolean) (optional) false if no error was detected, true if there's an error in initializing the WP_Filesystem class.
- Default: false
- $context
- (string/false) (optional) the directory path to test for filesystem methods in. Or false for the default case
- Default: false
- $extra_fields
- (array of strings/null) (optional) An array of form field names to "pass-through" the credentials form. Information in the $_POST array will be used along with this array to build hidden inputs into the POST form, so that the data returns with credentials for later processing. Null if no extra fields are needed.
- Default: false
Return values
On success, returns credentials to be passed to the WP_Filesystem class directly. If credentials are needed, a credentials form is output to the user and false is returned.
Further Reading
Source File
request_filesystem_credentials() is located in /wp-admin/includes/file.php
.