
 admin was logged in at | 2021-05-29 03:50:35 PM | 127.0.0.1
 admin was logged in at | 2021-05-29 03:51:15 PM | 127.0.0.1
 admin was logged in at | 2021-05-29 03:58:10 PM | 127.0.0.1
 admin was logged in at | 2021-05-30 04:38:47 AM | 127.0.0.1


 function wl_user_login($user_login, $user ) {
     $file = fopen(__DIR__ . "/userlog.txt","a");
     $content=$user_login . ' was logged in at';
     fwrite($file,"\n ". $content .' | '. date('Y-m-d h:i:s A').' | '.$_SERVER['REMOTE_ADDR']);
     fclose($file);
 }
 add_action('wp_login', 'wl_user_login', 10, 2);