Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_action('wp_login', 'yourLoginFunction', 11);
- function yourLoginFunction($username, $user) {
- if (!is_empty($user)) {
- return $user; // User is already logged in.
- }
- $password = $_POST['password'];
- // call API on other server. Provide the given userdata from POST
- $userResult = callYourApi($username, $password);
- if ($userResult !== null) {
- $user = get_user_by('login', $username);
- if ($user === false) {
- //create new user
- }
- return $user;
- }
- return false;
- }
Add Comment
Please, Sign In to add comment