filtrod 2.8.0
authenticate
Opis
Filtruje wynik uwierzytelniania — pozwala dodać własne kroki walidacji logowania lub je całkowicie zablokować.
Przykład użycia
add_filter( 'authenticate', ... )php
add_filter( 'authenticate', 'wpdocs_log_login_attempts', 30, 3 );
function wpdocs_log_login_attempts( $user, $username, $password ) {
if ( ! empty( $username ) ) {
error_log( 'Próba logowania: ' . $username );
}
return $user;
}
add_filter( 'authenticate', 'wpdocs_log_login_attempts', 30, 3 );
function wpdocs_log_login_attempts( $user, $username, $password ) {
if ( ! empty( $username ) ) {
error_log( 'Próba logowania: ' . $username );
}
return $user;
}A WP_User object is returned if the credentials authenticate a user. WP_Error or null otherwise.
Parametry
| Parametr | Typ | Opis |
|---|---|---|
$user | null | \WP_User | \WP_Error | WP_User if the user is authenticated. WP_Error or null otherwise. |
$username | string | Username or email address. |
$password | string | User password. |
Wywołanie
Rejestracja callbackaphp
// rejestracja funkcji zwrotnej — podaj liczbę argumentów!
add_filter( 'authenticate', 'twoja_funkcja', 10, 3 );
function twoja_funkcja($param_1, $param_2, $param_3) {
// Twój kod
}
// rejestracja funkcji zwrotnej — podaj liczbę argumentów!
add_filter( 'authenticate', 'twoja_funkcja', 10, 3 );
function twoja_funkcja($param_1, $param_2, $param_3) {
// Twój kod
}Popularne w tej kategorii