Advertisement
verygoodplugins

Untitled

May 29th, 2019
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.70 KB | None | 0 0
  1. function wpf_true_auto_login() {
  2.  
  3.     if( ! isset( $_GET['cid'] ) ) {
  4.         return;
  5.     }
  6.    
  7.     if( ! isset( $_GET['key'] ) || $_GET['key'] != wp_fusion()->settings->get( 'access_key' ) ) {
  8.         return;
  9.     }
  10.  
  11.     $contact_id = sanitize_text_field( $_GET['cid'] );
  12.     $user_id = wp_fusion()->user->get_user_id( $contact_id );
  13.  
  14.     if( empty( $user_id ) || user_can( $user_id, 'manage_options' ) ) {
  15.         return;
  16.     }
  17.  
  18.     $user = get_user_by( 'id', $user_id );
  19.  
  20.     if( ! $user->user_email == $_GET['email'] ) {
  21.         return;
  22.     }
  23.  
  24.     // Login
  25.     wp_set_current_user( $user_id, $user->user_login );
  26.     wp_set_auth_cookie( $user_id );
  27.     do_action( 'wp_login', $user->user_login, $user );
  28.  
  29. }
  30.  
  31. add_action('init', 'wpf_true_auto_login');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement