function amuRegisterFromForm() { global $wpdb, $current_user; $procs = (int) $_POST['processes']; $proclist = explode(' ', trim($_POST['proclist'])); $confirmationStack = array(); if ($procs > 0) { $line = 1; while ($line <= $procs) { $userInfoArray = array(); foreach ($proclist as $linevalue) { $userInfoArray[$linevalue] = trim($_POST[$linevalue . $line]); } //if username line is not blank if ($userInfoArray['user_login'] !== '') { //create new user object $newUser = new amuUserObject($userInfoArray); //register initial user info $newid = $newUser->amuRegisterUser(); if (is_int($newid)) { //update users data based on input $newUser->amuUpdateUserData(); //send user a notification email $newUser->amuSendUserEmail(); //add any additional meta data fields $newUser->amuUpdateUserMeta($userInfoArray); //set confirmation message $confirmUpdate = '<p><strong>' . $line . '</strong>. ' . __('New user successfully registered.', 'amulang') . ' <strong>' . __('Login', 'amulang') . ':</strong> ' . $newUser->user_login . ' <strong>' . __('Password', 'amulang') . ':</strong> ' . $newUser->user_pass . ' <strong>' . __('Email', 'amulang') . ':</strong> ' . $newUser->user_email . '</p>'; } else { //return failure message $confirmUpdate = '<p>' . $line . '. ' . $newid . '</p>'; } //add success or failure message to stack $confirmationStack[] = $confirmUpdate; //kill reusable objects and arrays unset($newUser); unset($userInfoArray); } //increment line number $line++; } echo '<h3>' . __('Results of your new user registrations', 'amulang') . '</h3>'; //admin notifications $adminUser = new amuAdminObject(); $sendRegResults = $adminUser->amuAdminConfirmation($confirmationStack); $stackDisplay = $adminUser->amuShowStack($confirmationStack); //print notifications to screen echo $sendRegResults; echo '<div class="stackwrap">' . $stackDisplay . '</div>'; } else { echo '<p>' . __('Error retrieving processes. Please try again.', 'amulang') . '</p>'; } }
function amuCSVToRegister() { global $wpdb; $rawCSVdata = $_POST['filecontents']; $parsedData = parse_csv($rawCSVdata); $reorderedData = reorder_csv($parsedData); $userData = json_decode($reorderedData); $confirmationStack = array(); $line = 0; //pull out each user data array and process individually foreach ($userData as $userRow) { $line++; if ($userRow->user_login !== '') { //create new user object $newUser = new amuUserObject($userRow); //register initial user info $newid = $newUser->amuRegisterUser(); if (is_int($newid)) { //update users data based on input $newUser->amuUpdateUserData(); //send user a notification email $newUser->amuSendUserEmail(); //add any additional meta data fields $newUser->amuUpdateUserMeta($userRow); //set confirmation message $confirmUpdate = '<p><strong>' . $line . '</strong>. ' . __('New user successfully registered.', 'amulang') . ' <strong>' . __('Login', 'amulang') . ':</strong> ' . $newUser->user_login . ' <strong>' . __('Password', 'amulang') . ':</strong> ' . $newUser->user_pass . ' <strong>' . __('Email', 'amulang') . ':</strong> ' . $newUser->user_email . '</p>'; } else { //return failure message $confirmUpdate = '<p>' . $line . '. ' . $newid . '</p>'; } //kill reusable object unset($newUser); } else { //return failure message $confirmUpdate = '<p>' . $line . '. ' . __('No user_login was found. This line was skipped.', 'amulang') . '</p>'; } //add success or failure message to stack $confirmationStack[] = $confirmUpdate; } echo '<h3>' . __('Results of your new user registrations', 'amulang') . '</h3>'; //admin notifications $adminUser = new amuAdminObject(); $sendRegResults = $adminUser->amuAdminConfirmation($confirmationStack); $stackDisplay = $adminUser->amuShowStack($confirmationStack); //print notifications to screen echo $sendRegResults; echo '<div class="stackwrap">' . $stackDisplay . '</div>'; }