Filter hook 'request_filesystem_credentials'

in WP Core File wp-admin/includes/file.php at line 2390

View Source

request_filesystem_credentials

Filter Hook
Description
Filters the filesystem credentials. Returning anything other than an empty string will effectively short-circuit output of the filesystem credentials form, returning that value instead. A filter should return true if no filesystem credentials are required, false if they are required but have not been provided, or an array of credentials if they are required and have been provided.

Hook Information

File Location wp-admin/includes/file.php View on GitHub
Hook Type Filter
Line Number 2390

Hook Parameters

Type Name Description
mixed $credentials Credentials to return instead. Default empty string.
string $form_post The URL to post the form to.
string $type Chosen type of filesystem.
bool|WP_Error $error Whether the current request has failed to connect, or an error object.
string $context Full path to the directory that is tested for being writable.
array $extra_fields Extra POST fields.
bool $allow_relaxed_file_ownership Whether to allow Group/World writable.

Usage Examples

Basic Usage
<?php
// Hook into request_filesystem_credentials
add_filter('request_filesystem_credentials', 'my_custom_filter', 10, 7);

function my_custom_filter($credentials, $form_post, $type, $error, $context, $extra_fields, $allow_relaxed_file_ownership) {
    // Your custom filtering logic here
    return $credentials;
}

Source Code Context

wp-admin/includes/file.php:2390 - How this hook is used in WordPress core
<?php
2385  	 * @param string        $context                      Full path to the directory that is tested for
2386  	 *                                                    being writable.
2387  	 * @param array         $extra_fields                 Extra POST fields.
2388  	 * @param bool          $allow_relaxed_file_ownership Whether to allow Group/World writable.
2389  	 */
2390  	$req_cred = apply_filters( 'request_filesystem_credentials', '', $form_post, $type, $error, $context, $extra_fields, $allow_relaxed_file_ownership );
2391  
2392  	if ( '' !== $req_cred ) {
2393  		return $req_cred;
2394  	}
2395  

PHP Documentation

<?php
/**
	 * Filters the filesystem credentials.
	 *
	 * Returning anything other than an empty string will effectively short-circuit
	 * output of the filesystem credentials form, returning that value instead.
	 *
	 * A filter should return true if no filesystem credentials are required, false if they are required but have not been
	 * provided, or an array of credentials if they are required and have been provided.
	 *
	 * @since 2.5.0
	 * @since 4.6.0 The `$context` parameter default changed from `false` to an empty string.
	 *
	 * @param mixed         $credentials                  Credentials to return instead. Default empty string.
	 * @param string        $form_post                    The URL to post the form to.
	 * @param string        $type                         Chosen type of filesystem.
	 * @param bool|WP_Error $error                        Whether the current request has failed to connect,
	 *                                                    or an error object.
	 * @param string        $context                      Full path to the directory that is tested for
	 *                                                    being writable.
	 * @param array         $extra_fields                 Extra POST fields.
	 * @param bool          $allow_relaxed_file_ownership Whether to allow Group/World writable.
	 */
Quick Info
  • Hook Type: Filter
  • Parameters: 7
  • File: wp-admin/includes/file.php
Related Hooks

Related hooks will be displayed here in future updates.