Beispiel #1
0
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>';
    }
}
Beispiel #2
0
function amuProcessEmailInput($regType)
{
    global $wpdb;
    //clean up input
    $rawEmailList = trim($_POST['emailfillbox']);
    $order = array('\\r\\n', '\\n', '\\r', ' ');
    $replace = '';
    $cleanEmailList = str_replace($order, $replace, $rawEmailList);
    //verify array is not empty
    if ($cleanEmailList !== '') {
        $verifySymbol = strpos($cleanEmailList, '@');
        if ($verifySymbol == false) {
            $emailListError = '<p class="amu_error">' . __('Error: No valid email addresses were found in your input data! Please try again.', 'amulang') . '</p>';
            addByEmailList($emailListError);
            $infotype = 'emaillisting';
            showPluginInfo($infotype);
        } else {
            //new array for user data
            $userArray = array();
            $emailListArray = explode(',', $cleanEmailList);
            foreach ($emailListArray as $userEntry) {
                //create username/email vars
                $em_useremail = $userEntry;
                $pos = strpos($em_useremail, '@');
                $em_username = substr($em_useremail, 0, $pos);
                //verify is email address
                if ($pos !== false) {
                    $userEntryArray = array();
                    //push some values plus some dummy ones
                    $userEntryArray['user_login'] = $em_username;
                    $userEntryArray['user_pass'] = '';
                    $userEntryArray['user_email'] = $em_useremail;
                    //push role variable if it exists
                    $theDefRole = get_option('amu_setallroles');
                    if ($theDefRole == 'notset') {
                        $userEntryArray['role'] = '';
                    } else {
                        $userEntryArray['role'] = $theDefRole;
                    }
                    if ($regType == 'form') {
                        //send some other ones
                        $userEntryArray['first_name'] = '';
                        $userEntryArray['last_name'] = '';
                        //add selected standard values
                        $stdamumetaoption = get_option('amu_showblankmeta');
                        if ($stdamumetaoption !== '') {
                            $stdMetaOptions = json_decode(get_option('amu_showblankmeta'));
                            foreach ($stdMetaOptions as $stdmeta) {
                                $userEntryArray[$stdmeta->keyname] = '';
                            }
                        }
                        //add custom meta options
                        $extraamumetaoptions = get_option('amu_extrameta');
                        if ($extraamumetaoptions !== '') {
                            $extraMetaOptions = json_decode(get_option('amu_extrameta'));
                            foreach ($extraMetaOptions as $extmeta) {
                                $userEntryArray[$extmeta->keyname] = '';
                            }
                        }
                    }
                    //add this entry array to full user data array
                    $userArray[] = $userEntryArray;
                    //kill it for reuse
                    unset($userEntryArray);
                }
            }
            //encode full user array
            $userData = json_encode($userArray);
            //send to form creator
            if ($regType == 'form') {
                $source = 'email';
                $newForm = new amuFormCreator($source, $userData);
                $newForm->amuCreateFormInterface();
                //show form field info
                $infotype = 'formfields';
                showPluginInfo($infotype);
                //or process direct
            } else {
                if ($regType == 'direct') {
                    $eachUserData = json_decode($userData);
                    $confirmationStack = array();
                    $line = 0;
                    foreach ($eachUserData 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();
                                //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>';
                    //or throw error
                } else {
                    echo '<p>' . __('Unknown request.', 'amulang') . '</p>';
                }
            }
        }
    } else {
        $emailListError = '<p class="amu_error">' . __('Error: No valid email addresses were found in your input data! Please try again.', 'amulang') . '</p>';
        addByEmailList($emailListError);
        $infotype = 'emaillisting';
        showPluginInfo($infotype);
    }
}
Beispiel #3
0
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>';
}