Title: wp_connectors_get_application_password_credentials
Published: August 20, 2026

---

# wp_connectors_get_application_password_credentials( array $auth ): array{username:

## In this article

 * [Description](https://developer.wordpress.org/reference/functions/wp_connectors_get_application_password_credentials/?output_format=md#description)
 * [Parameters](https://developer.wordpress.org/reference/functions/wp_connectors_get_application_password_credentials/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/wp_connectors_get_application_password_credentials/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/wp_connectors_get_application_password_credentials/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/wp_connectors_get_application_password_credentials/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/wp_connectors_get_application_password_credentials/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/functions/wp_connectors_get_application_password_credentials/?output_format=md#wp--skip-link--target)

This function’s access is marked private. This means it is not intended for use 
by plugin or theme developers, only by core. It is listed here for completeness.

Resolves application-password credentials for a connector.

## 󠀁[Description](https://developer.wordpress.org/reference/functions/wp_connectors_get_application_password_credentials/?output_format=md#description)󠁿

Checks in order: environment variable, PHP constant, database. The environment variable
and constant are only checked when their respective names are provided, and must
contain the credentials as a single `username:password` string. A non-empty environment
variable or constant that cannot be parsed as `username:password` is reported with`
_doing_it_wrong()` and ignored, so resolution falls through to the next source.

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/wp_connectors_get_application_password_credentials/?output_format=md#parameters)󠁿

 `$auth`arrayrequired

The connector’s authentication configuration.

## 󠀁[Return](https://developer.wordpress.org/reference/functions/wp_connectors_get_application_password_credentials/?output_format=md#return)󠁿

 array{username: string, password: string, source: string} Resolved credentials 
and their source: `'env'`, `'constant'`, `'database'`, or `'none'`.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/wp_connectors_get_application_password_credentials/?output_format=md#source)󠁿

    ```php
    function wp_connectors_get_application_password_credentials( array $auth ): array {
    	// Check environment variable first.
    	$env_var_name = $auth['env_var_name'] ?? '';
    	if ( '' !== $env_var_name ) {
    		$env_value = getenv( $env_var_name );
    		if ( false !== $env_value && '' !== $env_value ) {
    			$credentials = wp_connectors_parse_application_password_credentials( $env_value );
    			if ( '' !== $credentials['username'] && '' !== $credentials['password'] ) {
    				$credentials['source'] = 'env';
    				return $credentials;
    			}

    			_doing_it_wrong(
    				__FUNCTION__,
    				sprintf(
    					/* translators: %s: Environment variable name. */
    					__( 'The %s environment variable must contain application password credentials in "username:password" format.' ),
    					esc_html( $env_var_name )
    				),
    				'7.1.0'
    			);
    		}
    	}

    	// Check PHP constant.
    	$constant_name = $auth['constant_name'] ?? '';
    	if ( '' !== $constant_name && defined( $constant_name ) ) {
    		$const_value = constant( $constant_name );
    		if ( is_string( $const_value ) && '' !== $const_value ) {
    			$credentials = wp_connectors_parse_application_password_credentials( $const_value );
    			if ( '' !== $credentials['username'] && '' !== $credentials['password'] ) {
    				$credentials['source'] = 'constant';
    				return $credentials;
    			}

    			_doing_it_wrong(
    				__FUNCTION__,
    				sprintf(
    					/* translators: %s: PHP constant name. */
    					__( 'The %s constant must contain application password credentials in "username:password" format.' ),
    					esc_html( $constant_name )
    				),
    				'7.1.0'
    			);
    		}
    	}

    	// Check database.
    	$stored   = get_option( $auth['setting_name'] ?? '', array() );
    	$username = is_array( $stored ) && isset( $stored['username'] ) && is_string( $stored['username'] ) ? $stored['username'] : '';
    	$password = is_array( $stored ) && isset( $stored['password'] ) && is_string( $stored['password'] ) ? $stored['password'] : '';

    	return array(
    		'username' => $username,
    		'password' => $password,
    		'source'   => '' !== $username && '' !== $password ? 'database' : 'none',
    	);
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/connectors.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.1/src/wp-includes/connectors.php#L522)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.1/src/wp-includes/connectors.php#L522-L579)

## 󠀁[Related](https://developer.wordpress.org/reference/functions/wp_connectors_get_application_password_credentials/?output_format=md#related)󠁿

| Uses | Description | 
| [wp_connectors_parse_application_password_credentials()](https://developer.wordpress.org/reference/functions/wp_connectors_parse_application_password_credentials/)`wp-includes/connectors.php` |

Parses a `username:password` credentials string.

  | 
| [__()](https://developer.wordpress.org/reference/functions/__/)`wp-includes/l10n.php` |

Retrieves the translation of $text.

  | 
| [esc_html()](https://developer.wordpress.org/reference/functions/esc_html/)`wp-includes/formatting.php` |

Escaping for HTML blocks.

  | 
| [_doing_it_wrong()](https://developer.wordpress.org/reference/functions/_doing_it_wrong/)`wp-includes/functions.php` |

Marks something as being incorrectly called.

  | 
| [get_option()](https://developer.wordpress.org/reference/functions/get_option/)`wp-includes/option.php` |

Retrieves an option value based on an option name.

  |

[Show 3 more](https://developer.wordpress.org/reference/functions/wp_connectors_get_application_password_credentials/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/wp_connectors_get_application_password_credentials/?output_format=md#)

| Used by | Description | 
| [_wp_connectors_get_connector_script_module_data()](https://developer.wordpress.org/reference/functions/_wp_connectors_get_connector_script_module_data/)`wp-includes/connectors.php` |

Exposes connector settings to the connectors-wp-admin script module.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/wp_connectors_get_application_password_credentials/?output_format=md#changelog)󠁿

| Version | Description | 
| [7.1.0](https://developer.wordpress.org/reference/since/7.1.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_connectors_get_application_password_credentials%2F)
before being able to contribute a note or feedback.