rAthus

[WordPress] [PHP] force user login by username

Sep 15th, 2021
903
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. $user_login = 'userlogin';
  4. $user = get_userdatabylogin($user_login);
  5. $user_id = $user->ID;
  6. wp_set_current_user($user_id, $user_login);
  7. wp_set_auth_cookie($user_id);
  8. do_action('wp_login', $user_login);
  9.  
RAW Paste Data