Skip to content

Instantly share code, notes, and snippets.

@vanpariyar
Created July 23, 2020 17:08
Show Gist options
  • Save vanpariyar/a21e499a2a884bf710be7564e165f4c1 to your computer and use it in GitHub Desktop.
Save vanpariyar/a21e499a2a884bf710be7564e165f4c1 to your computer and use it in GitHub Desktop.
<?php
/**
* Send Email For OTP
* Using WP_rand ( because it is cryptographically secure then PHP rand ).
*/
$otp = wp_rand( 100000, 999999 );
$timestemp = current_time('timestamp');
/**
* OTP stemp Format( TimeStemp:OtpString ) for Ex. 15000000245455:465478
*/
$user_string = current_time('timestamp') .':'. wp_rand( 100000, 999999 );
update_user_meta( $user->ID, 'pass_stemp', $user_string );
$fields = [
'otp' => $otp,
'email'=> $user_email,
'name'=> $user->user_firstname,
];
/** SEND THis to email */
/**
*FOr validation code
*/
get user meta
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment