[insert_php]
global $wpdb;
$uzr = get_current_user_id();
//$credits = mycred_get_users_cred($uzr);
$emailid=$_POST[’emailid’];
echo $emailid.PHP_EOL;
$fname1=$_POST[‘firstname1’];
$lname1=$_POST[‘lastname1′];
$email1=$_POST[’email1′];
$newusername1=$fname1.$lname1;
$fname2=$_POST[‘firstname2’];
$lname2=$_POST[‘lastname2′];
$email2=$_POST[’email2′];
$newusername2=$fname2.$lname2;
$fname3=$_POST[‘firstname3’];
$lname3=$_POST[‘lastname3′];
$email3=$_POST[’email3′];
$newusername3=$fname3.$lname3;
$fname4=$_POST[‘firstname4’];
$lname4=$_POST[‘lastname4′];
$email4=$_POST[’email4′];
$newusername4=$fname4.$lname4;
$fname5=$_POST[‘firstname5’];
$lname5=$_POST[‘lastname5′];
$email5=$_POST[’email5′];
$newusername5=$fname5.$lname5;
$current_user = wp_get_current_user();
echo ‘User ID: ‘ . $current_user->ID . ‘
‘;
$all_meta_for_user = get_user_meta( $current_user->ID );
$formnumber=$current_user->description;
echo “Form number “.$formnumber.PHP_EOL;
echo “Adding users….”;echo “
“;echo “
“;
echo $email1.PHP_EOL;
echo $email2.PHP_EOL;
echo $email3.PHP_EOL;
echo $email4.PHP_EOL;
echo $email5.PHP_EOL;
//$newusername = ‘YOURUSERNAME’;
$newpassword = ‘password123’;
//$newemail = ‘YOUREMAIL@TEST.com’;
$testing=’HAHA’;
if ( !username_exists($newusername1) && !email_exists($email1) )
{
$length=20;
$characters = ‘0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ’;
$charactersLength = strlen($characters);
$randomString = ”;
for ($i = 0; $i < $length; $i++) {
$randomString .= $characters[rand(0, $charactersLength - 1)];}
//echo $randomString.PHP_EOL;
$meta_key = "pkg_autologin_code";
$timestampz=time();
$tokenparta = $randomString;
$key = $timestampz*3 . $tokenparta;
$website= "https://www.skillsaudit.co.uk/skillsaudit2?autologin_code=".$key;
echo "Website ".$website.PHP_EOL;
$userdata = array(
'user_login' => $newusername1,
‘user_url’ => $website,
‘display_name’ => $emailid,
‘user_pass’ => $newpassword,
‘first_name’ => $fname1,
‘user_email’ => $email1,
‘description’ => $emailid,
‘last_name’ => $lname1,
);
$user_id = wp_insert_user( $userdata ) ;
//On success
if ( ! is_wp_error( $user_id ) ) {
echo “User created : “. $user_id;
$username=$newusername1;
//$length=30;
//$characters = ‘0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ’;
//$charactersLength = strlen($characters);
//$randomString = ”;
//for ($i = 0; $i < $length; $i++) {
// $randomString .= $characters[rand(0, $charactersLength - 1)];}
//echo $randomString.PHP_EOL;
//$meta_key = "pkg_autologin_code";
//$timestampz=time();
//$tokenparta = $randomString;
//$key = $timestampz*3 . $tokenparta;
echo "KEY IS".$key.PHP_EOL;
$targetuser = get_user_by('login', $username);
$targetuserId = $targetuser->ID;
echo “Target user ID is”.$targetuserId.PHP_EOL;
update_user_meta( $targetuserId, $meta_key, $key );
}
}
if ( !username_exists($newusername2) && !email_exists($email2) )
{
$userdata = array(
‘user_login’ => $newusername2,
‘user_url’ => $website,
‘display_name’ => $emailid,
‘user_pass’ => $newpassword,
‘first_name’ => $fname2,
‘user_email’ => $email2,
‘description’ => $emailid,
‘last_name’ => $lname2,
);
$user_id = wp_insert_user( $userdata ) ;
//On success
if ( ! is_wp_error( $user_id ) ) {
echo “User created : “. $user_id;
}
}
if ( !username_exists($newusername3) && !email_exists($email3) )
{
$userdata = array(
‘user_login’ => $newusername3,
‘user_url’ => $website,
‘display_name’ => $emailid,
‘user_pass’ => $newpassword,
‘first_name’ => $fname3,
‘user_email’ => $email3,
‘description’ => $emailid,
‘last_name’ => $lname3,
);
$user_id = wp_insert_user( $userdata ) ;
//On success
if ( ! is_wp_error( $user_id ) ) {
echo “User created : “. $user_id;
//mycred_subtract( ‘reference’, $uzr, -1, $email13);
}
}
if ( !username_exists($newusername4) && !email_exists($email4) )
{
$userdata = array(
‘user_login’ => $newusername4,
‘user_url’ => $website,
‘display_name’ => $emailid,
‘user_pass’ => $newpassword,
‘first_name’ => $fname4,
‘user_email’ => $email4,
‘description’ => $emailid,
‘last_name’ => $lname4,
);
$user_id = wp_insert_user( $userdata ) ;
//On success
if ( ! is_wp_error( $user_id ) ) {
echo “User created : “. $user_id;
//mycred_subtract( ‘reference’, $uzr, -1, $email14);
}
}
if ( !username_exists($newusername5) && !email_exists($email5) )
{
$userdata = array(
‘user_login’ => $newusername5,
‘user_url’ => $website,
‘display_name’ => $emailid,
‘user_pass’ => $newpassword,
‘first_name’ => $fname5,
‘user_email’ => $email5,
‘description’ => $emailid,
‘last_name’ => $lname5,
);
$user_id = wp_insert_user( $userdata ) ;
//On success
if ( ! is_wp_error( $user_id ) ) {
echo “User created : “. $user_id;
//mycred_subtract( ‘reference’, $uzr, -1, $email15);
}
}
//header(“Location: manage”);
//die();
[/insert_php]