Last active
June 11, 2021 21:22
-
-
Save tzkmx/e0c9c99c9a7685a10c25b3ee0b42d12d to your computer and use it in GitHub Desktop.
basic passwordless login wordpress
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require __DIR__ . '/../wp-load.php'; | |
// si envías token, antes de esta línea tendrías que validar que el token es vigente, y de ahí obtener el token del usuario directo | |
if(!isset($_POST['email'])) { | |
$email = $_POST['email']; | |
} | |
$user = get_user_by('login', $email); | |
if (is_null($user)) { | |
invalidAuth(); | |
} | |
$userId = $user->ID; | |
wp_clear_auth_cookie(); | |
wp_set_current_user ( $userId ); | |
wp_set_auth_cookie( $userId ); | |
function invalidAuth() { | |
http_response_code(401); | |
echo "No se encontró usuario registrado como Socio\n"; | |
exit(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment