login_errors

最后更新于:2021-11-27 04:04:42

apply_filters( ‘login_errors’, string $errors )

Filters the error messages displayed above the login form.

参数

$errors

(string)
Login error message.

源文件

文件: gc-login.php

View on Trac

add_filter( 'login_errors', function( $error ) {
	global $errors;
	$err_codes = $errors->get_error_codes();

	// Invalid username.
	// Default: '<strong>ERROR</strong>: Invalid username. <a href="https://docs.gechiui.com/hooks/login_errors/%s">Lost your password</a>?'
	if ( in_array( 'invalid_username', $err_codes ) ) {
		$error = '<strong>ERROR</strong>: Invalid username.';
	}

	// Incorrect password.
	// Default: '<strong>ERROR</strong>: The password you entered for the username <strong>%1$s</strong> is incorrect. <a href="https://docs.gechiui.com/hooks/login_errors/%2$s">Lost your password</a>?'
	if ( in_array( 'incorrect_password', $err_codes ) ) {
		$error = '<strong>ERROR</strong>: The password you entered is incorrect.';
	}

	return $error;
} );