admin_url( 'admin-ajax.php' ) ) ); } function multiadd_actions() { wp_enqueue_script( "multiadd_actions", plugins_url( "multiadd-actions.js", __FILE__ ), array( 'jquery' ) ); wp_localize_script( "multiadd_actions", "MySecureAjax", array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) ); } function addmultiuser_style() { wp_register_style($handle = 'amu_css_style', $src = plugins_url('amustyle.css', __FILE__), $deps = array(), $ver = '1.2.0', $media = 'all'); wp_enqueue_style('amu_css_style'); } function set_default_options() { global $current_user, $wpdb; get_currentuserinfo(); $defaultAdminEmail = $current_user->user_email; $sitelogurl = site_url(); $defaultUserEmailHead = 'Your New User Account Information on [sitename]'; $defaultUserEmailText = '

You have been registered as a user on [sitename]

You may now log into the site at [siteloginurl]

Your username is [username] and your password is [password]

Regards,
[sitename] Admin

[siteurl]

'; if(!get_option('amu_usernotify')) { update_option( 'amu_usernotify', 'yes' ); } if(!get_option('amu_confirmation')) { update_option( 'amu_confirmation', 'yes' ); } if(!get_option('amu_setallroles')) { update_option( 'amu_setallroles', 'notset' ); } if(!get_option('amu_validatestrict')) { update_option( 'amu_validatestrict', 'no' ); } if(!get_option('amu_validatemail')) { update_option( 'amu_validatemail', 'yes' ); } if(!get_option('amu_forcefill')) { update_option( 'amu_forcefill', 'no' ); } if(!get_option('amu_defadminemail')) { update_option( 'amu_defadminemail', $defaultAdminEmail ); } if(!get_option('amu_siteloginurl')) { update_option( 'amu_siteloginurl', $sitelogurl ); } if(!get_option('amu_useremailhead')) { update_option( 'amu_useremailhead', $defaultUserEmailHead ); } if(!get_option('amu_useremailtext')) { update_option( 'amu_useremailtext', $defaultUserEmailText ); } } //MAIN FUNCTION function add_multiple_users() { //test again for admin priviledges if (!current_user_can('manage_options') ) { wp_die( __('You do not have sufficient permissions to access this page.') ); } //globals for functions global $current_user, $wpdb; get_currentuserinfo(); $thisUserEmail = $current_user->user_email; $thisBlogName = get_bloginfo('name'); $thisBlogUrl = site_url(); $thisLoginUrl = get_option('amu_siteloginurl'); $confirmationStack = ''; //begin wrap class echo '
'; echo '
'; //if saving options... if ( isset($_POST['setgenopt'] ) ) { setGeneralOptions(); echo '
'; echo '

General Options have been saved.

'; echo '
'; } //if submitted if ( isset($_POST['addnewusers'] ) ) { //new users added message echo '
'; echo '

New User User Accounts Processed.

'; echo '
'; } //SHOW ADDING FORM echo '

Add Multiple Users

'; echo '

It is recommended that you modify your Settings before using one of the New User tools.
'; echo 'Please read the plugin information provided on each page regarding the use of each function.

'; echo '
'; //show toolbar showToolbar(); //if no post settings made if (empty($_POST)) { $infotype = 'general'; showPluginInfo($infotype); } // <=========== CREATE NEW USER ACCOUNTS ===============================================================> if ( isset($_POST['addnewusers'] ) ) { //GET GENERAL OPTION SETTINGS $sendEmail = get_option( 'amu_usernotify'); $yesConfirm = get_option('amu_confirmation'); $setAllRoles = get_option('amu_setallroles'); $validateStrict = get_option( 'amu_validatestrict'); $validateEmail = get_option('amu_validatemail'); $forceEmail = get_option('amu_forcefill'); $procs = $_POST['processes']; $userEmailSubject = get_option('amu_useremailhead'); $userEmailMsg = get_option('amu_useremailtext'); $userfromreply = get_option('amu_defadminemail'); //information feedback echo '
'; echo '

New User Information Added

'; echo '

Important: If you did not request this information emailed to you and you wish to save the information for future reference, please copy the New User Information section below IMMEDIATELY and save it for your records. It will not be available again if make any further selections you navigate away from this page.

'; echo '

If any of your users have not been added due to an error, please note these errors and try adding the users again.

'; echo '
'; echo '
'; echo '

New User Account Registration Details:

'; //run through registration lines by email for ( $icounter = 1; $icounter <= $procs; $icounter += 1 ) { //get username/password/email/additional vars $tempusername = trim($_POST['username'.$icounter]); $password = trim($_POST['password'.$icounter]); $email = trim($_POST['email'.$icounter]); $userRole = $_POST['roleSetter'.$icounter]; $firstname = $_POST['firstname'.$icounter]; $lastname = $_POST['lastname'.$icounter]; $website = $_POST['website'.$icounter]; $emailGen = 'valid'; //if username is not blank if ($tempusername != '') { //process username if ($validateStrict == 'yes') { $username = sanitize_user( $tempusername, true ); } else { $username = sanitize_user( $tempusername, false ); } //check if username exists if ( username_exists( $username ) ) { $fail_userexists = '

'.$icounter.'. Error: The user '.$username. ' already exists. Please try adding this user again with a different username.

'; $confirmationStack = $confirmationStack.$fail_userexists; echo $fail_userexists; //check if email exists } else if ( email_exists( $email ) ) { $fail_emailexists = '

'.$icounter.'. Error:: The email address entered <'.$email.'> for the user '.$username.' already exists. Please try adding this user again with a unique email.

'; $confirmationStack = $confirmationStack.$fail_emailexists; echo $fail_emailexists; } else { //process password if ( $password == '' ) { //generate random password if blank $password = wp_generate_password(); } //process email if ( $email == '' ) { if ( $forceEmail == 'no' ) { $fail_noemailadded = '

'.$icounter.'. Error:: No email address for the user '.$username.' was included. Please try adding this user again with a valid email address.

'; $email = ''; $confirmationStack = $confirmationStack.$fail_noemailadded; echo $fail_noemailadded; } else { //generate random email address $email = 'temp_'.$username.'@temp'.$username.'.fake'; $emailGen = 'generated'; } } else { //validate entered password if set if ( $validateEmail == 'yes' ) { if ( !is_email( $email ) ) { $fail_emailnotvalid = '

'.$icounter.'. Error:: New user '.$username.' was not added because the email address provided '.$email.' for this user was not valid. Please try again using a valid email address or disable email verification.

'; $email = ''; $confirmationStack = $confirmationStack.$fail_emailnotvalid; echo $fail_emailnotvalid; } } } //VERIFY ALL DATA EXISTS THEN PROCESS if ( ( $username != '' ) && ( $password != '' ) && ( $email != '' ) ) { //confirmation of addition of user $userSuccess = '

'.$icounter.'. Success! The user '.$username.' has been added. Email Address for this user is '.$email.'. Password for this user is '.$password.'

'; $confirmationStack = $confirmationStack.$userSuccess; echo $userSuccess; //create new wordpress user $newuser = wp_create_user( $username, $password, $email ); $wp_user_object = new WP_User($newuser); //id of new user $newuserID = $wp_user_object->ID; //set user first name if ($firstname != '') { update_user_meta( $newuserID, 'first_name', $firstname ); } //set user last name if ($lastname != '') { update_user_meta( $newuserID, 'last_name', $lastname ); } //set user web site if ($website != '') { wp_update_user( array ('ID' => $newuserID, 'user_url' => $website) ) ; } //set user role if ($setAllRoles == 'notset') { $wp_user_object->set_role($userRole); } else { $wp_user_object->set_role($setAllRoles); } unset($wp_user_object); //send password to new user? if (($sendEmail == 'yes') && ($emailGen == 'valid')) { //set up email $to = $email; //replace instances of shortcodes $emailkeywords = array('[sitename]', '[siteurl]', '[siteloginurl]', '[username]', '[password]', '[useremail]', '[fromreply]'); $emailreplaces = array($thisBlogName, ''.$thisBlogUrl.'',''.$thisLoginUrl.'', $username, $password, $to, $thisUserEmail); $subject = str_replace($emailkeywords, $emailreplaces, $userEmailSubject); $message = str_replace($emailkeywords, $emailreplaces, $userEmailMsg); //create valid header $headers = 'From: '.$userfromreply.' <'.$userfromreply.'>' . "\r\n"; //filter to create html email add_filter('wp_mail_content_type',create_function('', 'return "text/html"; ')); //send email wp_mail($to, $subject, $message, $headers); } } } } else { //no username entered in this line, skip and move on } } //SEND CONFIRMATION EMAIL TO LOGGED IN USER if ($yesConfirm == 'yes') { //set up confirmation email $confirmTo = $thisUserEmail; $confirmSubject = 'New User Account Information for '.$thisBlogName; $confirmMessage = '

This email is to confirm new user accounts for your website generated using the Add Multiple Users plugin.

All errors have also been included for reference when re-entering failed registrations.

'.$confirmationStack.'

End of message.

'; $confirmHeaders = 'From: '.$thisUserEmail.' <'.$thisUserEmail.'>' . "\r\n"; add_filter('wp_mail_content_type',create_function('', 'return "text/html"; ')); wp_mail($confirmTo, $confirmSubject, $confirmMessage, $confirmHeaders); echo '

This information has been emailed to your WordPress administrator email <'.$thisUserEmail.'> as requested.

'; } //on-screen confirmation if ($sendEmail == 'yes') { echo '

All users have been sent their login information (except where random emails were force-created).

'; } echo '
'; } // <=========== OPEN GENERAL OPTIONS ====================================================================> if ( isset($_POST['openg_genopt'] ) || isset($_POST['setgenopt'] )) { addGeneralOptions(); $infotype = 'settings'; showPluginInfo($infotype); } else { //general options are added in the background for reference by js echo '
'; addGeneralOptions(); echo '
'; } // <=========== MANUAL INPUT PROCESSES ==================================================================> //selected from toolbar if ( isset($_POST['input_manual'] ) ) { $manualInputError = ''; generateManualForm($manualInputError); } //defining number of rows required if ( isset($_POST['formshow_manual'] ) ) { //get number of lines $manprocs = $_POST['manualprocs']; //confirm post is not empty, is a number and is larger than zero if ($manprocs !== '' && ctype_digit($manprocs) && $manprocs > 0) { echo '
'; echo '

Add New Users by Manual Input

'; echo '

Please enter your new user information in the form below and click the Add All Users button to process your new user registrations.

'; echo '
'; //write form echo '
'; echo ' '; echo ' '; echo ' '; echo '
'; echo '
'; for ( $mancounter = 1; $mancounter <= $manprocs; $mancounter += 1 ) { formLinePrinter($mancounter, '', '', '', '', '', '', ''); } $mancounter -= 1; echo ' '; echo '
'; echo '
'; echo ' '; echo ' '; echo ' '; echo '
'; $infotype = 'formfields'; showPluginInfo($infotype); } else { $manualInputError = '

Error: either the number you entered was zero, empty, or a non-numeric character was entered. Please try again.

'; generateManualForm($manualInputError); } } // <=========== CSV/TXT UPLOAD PROCESSES ================================================================> //select from toolbar if ( isset($_POST['upload_csvtxt'] ) ) { $uploadFileError = ''; functionUploadFile($uploadFileError); $infotype = 'uploadfile'; showPluginInfo($infotype); } //add file text to textbox if ( isset($_POST['formshow_csvupload'] ) ) { //set ini for mac-created files ini_set('auto_detect_line_endings',true); if (is_uploaded_file($_FILES['csvuploader']['tmp_name'])) { $allowedExtensions = array("txt","csv"); if (!in_array(end(explode(".", strtolower($_FILES['csvuploader']['name']))), $allowedExtensions)) { $uploadFileError = '

Error: Not a valid file type! Only .csv and .txt files may be uploaded.

'; functionUploadFile($uploadFileError); $infotype = 'uploadfile'; showPluginInfo($infotype); } else { //SUCCESS $thefiledata = file_get_contents($_FILES['csvuploader']['tmp_name']); echo '
'; echo '

Add New Users by CSV Upload

'; echo '

The following user information has been extracted from your uploaded file.

'; echo '

Please review your extracted CSV data in the text field below and, if necessary, customize the column order appropriate to your CSV data structure (see Custom Column Order information below).

'; echo '
'; addFileSort(); echo '
'; echo ' '; echo '
'; echo '
'; echo ' '; echo '
'; $infotype = 'ordercolumns'; showPluginInfo($infotype); } } else { $uploadFileError = '

Error: Either you did not select a file to upload or there was an error getting the file! Please try again.

'; functionUploadFile($uploadFileError); $infotype = 'uploadfile'; showPluginInfo($infotype); } } //process into form if ( isset($_POST['formshow_csvprocess'] ) ) { echo '
'; echo '

Add New Users by CSV Upload

'; echo '

Please review the user information below to correct any errors or to add additional information for each user and click the Add All Users button to process your new user accounts.

'; echo '
'; $file = $_POST['filecontents']; $pasteddata = parse_csv($file); $data_rev = reorder_csv($pasteddata); $counter = 0; echo '
'; echo ' '; echo '
'; echo '
'; foreach($data_rev as $dataline) { $counter++; formLinePrinter($counter, $dataline[0], $dataline[1], $dataline[2], $dataline[3], $dataline[4], $dataline[5], $dataline[6]); } echo ''; echo '
'; //add submit button echo '
'; echo ' '; echo '
'; $infotype = 'formfields'; showPluginInfo($infotype); } // <=========== CSV/TXT MANUAL PROCESSES ================================================================> //select from toolbar if ( isset($_POST['input_csvbox'] ) ) { $csvinputerror = ''; addCSVInput($csvinputerror); $infotype = 'pastecsvtext'; showPluginInfo($infotype); $infotype = 'ordercolumns'; showPluginInfo($infotype); } //process text input from csv paste if ( isset($_POST['formshow_csvpaste'] ) ) { //get contents of csv input field $file = $_POST['csvpastebox']; //generate error if empty if($file == '') { $csvinputerror = '

No data was found in the CSV input field. Please try again!

'; addCSVInput($csvinputerror); $infotype = 'pastecsvtext'; showPluginInfo($infotype); $infotype = 'ordercolumns'; showPluginInfo($infotype); } else { //SUCCESS echo '
'; echo '

Add New Users by CSV Input

'; echo '

Please review the user information below to correct any errors or to add additional information for each user and click the Add All Users button to process your new user accounts.

'; echo '
'; $pasteddata = parse_csv($file); $data_rev = reorder_csv($pasteddata); $counter = 0; echo '
'; echo ' '; echo '
'; echo '
'; foreach($data_rev as $dataline) { $counter++; formLinePrinter($counter, $dataline[0], $dataline[1], $dataline[2], $dataline[3], $dataline[4], $dataline[5], $dataline[6]); } echo ' '; echo '
'; echo '
'; echo ' '; echo '
'; $infotype = 'formfields'; showPluginInfo($infotype); } } // <=========== EMAIL LIST PROCESSES ====================================================================> //select from toolbar if ( isset($_POST['input_email'] ) ) { $emailListError = ''; addByEmailList($emailListError); $infotype = 'emaillisting'; showPluginInfo($infotype); } //process text input into form lines if ( isset($_POST['formshow_email'] ) ) { //clean up input $rawEmailList = trim($_POST['emailfillbox']); $order = array('\r\n', '\n', '\r', ' '); $replace = ''; $cleanEmailList = str_replace($order, $replace, $rawEmailList); //if array is not empty if($cleanEmailList !== '') { $verifySymbol = strpos($cleanEmailList, '@'); if ($verifySymbol == false) { $emailListError = '

Error: No valid email addresses were found in your input data! Please try again.

'; addByEmailList($emailListError); } else { //SUCCESS echo '
'; echo '

Add New Users by Email List

'; echo '

Your email list was successfully converted to user listings.

'; echo '

Please review the user information below to correct any errors or to add additional information for each user and click the Add All Users button to process your new user accounts.

'; echo '
'; //create array $emailListArray = explode(',',$cleanEmailList); $counter = 0; echo '
'; echo ' '; echo '
'; echo '
'; //create new listing for array foreach($emailListArray as $userEntry) { $em_useremail = $userEntry; $pos = strpos($em_useremail, '@'); //changed to position and substr to be compatible pre php 5.3 (strstr function removed) if($pos !== false) { $counter++; $em_username = substr($em_useremail, 0, $pos); formLinePrinter($counter, $em_username, '', $em_useremail, '', '', '', ''); } } echo ' '; echo '
'; //add submit button echo '
'; echo ' '; echo '
'; $infotype = 'formfields'; showPluginInfo($infotype); } } else { $emailListError = '

Error: No valid email addresses were found in your input data! Please try again.

'; addByEmailList($emailListError); } } if ( isset($_POST['show_amuinfo'] ) ) { $infotype = 'general'; showPluginInfo($infotype); } echo '
'; echo '
'; } //MAIN FUNCTIONS function generateManualForm($manualInputError) { echo '
'; echo '

Add New Users by Manual Input

'; echo $manualInputError; echo '

Please enter the number of users you wish to add and press the Create Blank Form button.

'; echo '

You don\'t have to be too specific. You can add more as you go.

'; echo '
'; echo '
'; echo ' '; echo ' '; echo '
'; echo '
'; echo ' '; echo '
'; } //add input via csv input function addCSVInput($csvinputerror) { echo '
'; echo '

Add New Users by CSV Input

'; echo $csvinputerror; echo '

Paste your CSV info in the box below. Please read the Information on CSV Data below for information about your CSV data structure.

'; echo '

You will have the chance to review and customize user information in the next step before adding these users.

'; echo '
'; addFileSort(); echo '
'; echo ' '; echo '
'; echo '
'; echo ' '; echo '
'; } //add email list adding form with optional error function addByEmailList($emailListError) { echo '
'; echo '

Add New Users by Email List

'; echo $emailListError; echo '

Enter the email addresses of the users you wish to add to your WordPress site, separated by commas.

'; echo '

Usernames are automatically created from the first part of each email address you enter. All other information will be left blank.

'; echo '

You will have the chance to review and customize user information in the next step before adding these users.

'; echo '
'; echo '
'; echo ' '; echo '
'; echo '
'; echo ' '; echo '
'; } //add sorting mechanism function addFileSort() { echo '
'; echo '
'; } //add upload function form function functionUploadFile($uploadFileError) { echo '
'; echo '

Add New Users by CSV Upload

'; echo $uploadFileError; echo '

Choose a CSV or TXT file to upload using the file browser below.

'; echo '

Please read the Information on Uploading CSV and Text Files below for restrictions regarding the formatting of CSV information.

'; echo '

You will have the chance to review and customize user information in the next step before adding these users.

'; echo '
'; echo '
'; echo ''; echo '
'; echo '
'; echo ' '; echo '
'; } //create form lines from user input function formLinePrinter($fm_order, $fm_username, $fm_password, $fm_email, $fm_role, $fm_firstname, $fm_lastname, $fm_website) { global $current_user, $wpdb; get_currentuserinfo(); $fm_role = strtolower($fm_role); if ($fm_order & 1) { echo '
'; } else { echo '
'; } echo '
'; echo ' '.$fm_order.'.'; echo ' '; echo ' '; echo ' '; echo ' '; echo ' '; echo ' '; echo ' '; echo ' '; echo '
'; echo '
'; echo '  '; echo ' '; echo ' '; echo ' '; echo ' '; echo ' '; echo ' '; echo '
'; echo '
'; } //function for parsing csv function parse_csv($file,$comma=',',$quote='"',$newline="\n") { $db_quote = $quote . $quote; //clean up data $file = trim($file); $file = str_replace("\r\n",$newline,$file); $file = str_replace($db_quote,'"',$file); $file = str_replace(',",',',,',$file); $file .= $comma; $inquotes = false; $start_point = 0; $row = 0; //run for each line for($i=0; $i'; echo '

General Options

'; echo '

Please refer to the Information about Settings options at the bottom of this page for more information about these settings.

'; echo '
'; echo '
'; //send emails... echo '
'; echo ' '; echo ' '; echo '
'; //send confirmation email echo '
'; echo ' '; echo ' '; echo '
'; //validate emails... echo '
'; echo ' '; echo ' '; echo '
'; //username strict validation option... echo '
'; echo ' '; echo ' '; echo '
'; //force fill emails... echo '
'; echo ' '; echo ' '; echo '
'; //set all users to this role //retrieve set option value if (get_option('amu_setallroles')) { $rolesel = get_option('amu_setallroles'); } else { $rolesel = 'notset'; } echo '
'; echo ' '; echo ' '; echo '
'; echo '
'; echo '
'; echo '

Customize New User Notification Email

'; echo '
'; echo '
'; //customize new user delivered email echo '
'; $msghead = get_option('amu_useremailhead'); $msgtext = get_option('amu_useremailtext'); $sendemailsto = get_option('amu_defadminemail'); $siteloginurl = get_option('amu_siteloginurl'); echo '
'; echo '

Use the following settings to modify the notification email that new users receive when added via the plugin.

'; echo '

Please refer to the Information about Settings options at the bottom of this page for more information about these settings.

'; echo '

Valid shortcodes are: [sitename] [siteurl] [siteloginurl] [username] [password] [useremail] [fromreply]

'; echo '
'; //from email echo '
'; echo ''; echo ''; echo '
'; //custom login url echo '
'; echo ''; echo ''; echo '
'; //message header echo '
'; echo ''; echo ''; echo '
'; //message text echo '
'; echo ''; echo ''; echo '
'; echo '
'; echo '
'; echo '
'; echo ' '; echo '
'; } //set general options function setGeneralOptions() { global $current_user, $wpdb; get_currentuserinfo(); //get posted option info if ( isset($_POST['sendpswemails'] ) ) { $sendEmail = 'yes'; } else { $sendEmail = 'no'; } if ( isset($_POST['confirmEmail'] ) ) { $yesConfirm = 'yes'; } else { $yesConfirm = 'no'; } $setAllRoles = $_POST['allToRole']; if ( isset($_POST['forcefillemail'] ) ) { $forceEmail = 'yes'; } else { $forceEmail = 'no'; } if ( isset($_POST['validatemail'] ) ) { $validateEmail = 'yes'; } else { $validateEmail = 'no'; } if ( isset($_POST['validateStrict'] ) ) { $validateStrict = 'yes'; } else { $validateStrict = 'no'; } $emailCustomHead = $_POST['custemailhead']; $emailCustomText = $_POST['customemailtext']; $emailFromAddr = $_POST['custademail']; $emailsiteLog = $_POST['custlogurl']; //SAVE GENERAL OPTIONS update_option( 'amu_usernotify', $sendEmail ); update_option( 'amu_confirmation', $yesConfirm ); update_option( 'amu_setallroles', $setAllRoles ); update_option( 'amu_validatestrict', $validateStrict ); update_option( 'amu_validatemail', $validateEmail ); update_option( 'amu_forcefill', $forceEmail ); update_option( 'amu_useremailhead', $emailCustomHead ); update_option( 'amu_useremailtext', $emailCustomText ); update_option( 'amu_defadminemail', $emailFromAddr ); update_option( 'amu_siteloginurl', $emailsiteLog ); } //add new user options toolbar function showToolbar() { echo '
'; echo ' '; echo ' '; echo ' '; echo ' '; echo ' '; echo ' '; echo '
'; } //show information section function showPluginInfo($infotype) { //general information if ($infotype == 'general') { echo '
'; echo '

Add Multiple Users - General Plugin Information

'; echo '

This plugin enables an administrator to bulk add user registrations to a WordPress blog by using a variety of tools.

'; echo '

Please choose an option from the menu above to start registering users.

'; echo '
'; echo '
'; echo '

Functions provided by the Add Multiple Users plugin

'; echo '

Further help regarding individual plugin functions

'; echo '

While the functionality of this plugin is designed to be as intuitive as possible, there are some rules that must be followed when using the plugin\'s various functions.

'; echo '

More information about each function is provided at the bottom of each tool\'s page.

'; echo '
'; echo '
'; echo '

More Information

'; echo '

Visit the plugin page at http://www.happynuclear.com/sandbox/amu/add-multiple-users-for-wordpress.php for more information on the Add Multiple Users plugin.

'; echo '
'; //show info on form fields } else if ($infotype == 'emaillisting') { echo '
'; echo '

Information about the Email List function

'; echo '

This function takes a normal list of email addresses and converts them into new user information.

'; echo '

Note: Users are not immediately registered on the site when you click the Create User Information button. The email addresses you provide here will be used to create a form containing user information that you can review before registering these users on your site, allowing you to find errors and add additional information for each user if desired.

'; echo '

Adding your email list

'; echo '

When adding email addresses to the field above, each address must be separated by a comma (,) character. Even if you put the next address on the next line, there should be a comma between each email address.

'; echo '

Note: All blank spaces are stripped from the email list (meaning spaces after commas are not necessary or detrimental, however email addresses that contain spaces will be compressed).

'; echo '
'; //show info on form fields } else if ($infotype == 'formfields') { echo '
'; echo '

Information on form fields and settings

Usernames:
All new users must be given a unique username. Rows without a username are automatically skipped during the multiple registration process. Usernames cannot be changed once set. Usernames are automatically sanitized to strip out unsafe characters, but are not strictly sanitized.

Password:
May be set for each user, or left blank to generate a random password for that user. Passwords are not validated for their strength nor validity (yet). For more information on password strength and security, please visit the Hardening Wordpress page.

Email:
An unique, valid email address for each user is required (or use Force Fill option if emails are not available, see below). Emails will be checked for uniqueness and, if selected, validity.

FirstName, LastName, Website:
These parameters per user are optional and will be left blank if not filled in. Users or Administrators may update this information using the regular Wordpress user profile settings later. These fields are not validated.

'; echo '
'; //show upload file info } else if ($infotype == 'uploadfile') { echo '
'; echo '

Information on Uploading CSV and Text Files

'; echo '

Please choose either a .csv or .txt file to upload. All other file types are disallowed.

'; echo '

Recommended CSV Column Order

'; echo '

The plugin translates each line of your CSV (comma-separated values) data into seven variables: username, password, email, role, firstname, lastname and website, specifically in that order.

'; echo '

The best way to ensure your file is read properly is to structure your CSV data in this way if possible, separated by commas, using empty values in place of data you do not want to add. If you can export your CSV data in this format for upload here it will make importing your data quick and painless. If not, you can use the Customize function to specify your own line order.

'; echo '

Good Example 1: username,password,email,role,firstname,lastname,website - in this example the file is structured properly with all values added.

'; echo '

Good Example 2: username,,email,,firstname,lastname,website - in this example the "password" and "role" have been left blank, but the empty values are placed in the right order so the file will be read properly.

'; echo '

Bad Example 1: username,password,email,firstname,lastname,website - this example omits the "role" value and will translate incorrectly.

'; echo '

Bad Example 2: username,password,email,role,lastname,firstname,website - this example has the first and last name in the wrong order and will translate incorrectly.

'; echo '

Customizing the Column Order

'; echo '

If your CSV data is structured in a different way, you may upload your file now and use the Customize Column Order function on the next page.

'; echo '
'; //show upload file info } else if ($infotype == 'pastecsvtext') { echo '
'; echo '

Information on CSV Data

'; echo '

Recommended CSV Column Order

'; echo '

The plugin translates each line of your CSV (comma-separated values) data into seven variables: username, password, email, role, firstname, lastname and website, specifically in that order.

'; echo '

The best way to ensure your data is read properly is to structure your CSV data in this way if possible, separated by commas, using empty values in place of data you do not want to add. If you can export your CSV data in this format for use here it will make importing your data quick and painless. If not, you can use the Customize function to specify your own line order.

'; echo '

Good Example 1: username,password,email,role,firstname,lastname,website - in this example the file is structured properly with all values added.

'; echo '

Good Example 2: username,,email,,firstname,lastname,website - in this example the "password" and "role" have been left blank, but the empty values are placed in the right order so the file will be read properly.

'; echo '

Bad Example 1: username,password,email,firstname,lastname,website - this example omits the "role" value and will translate incorrectly.

'; echo '

Bad Example 2: username,password,email,role,lastname,firstname,website - this example has the first and last name in the wrong order and will translate incorrectly.

'; echo '
'; //show column ordering instructions } else if ($infotype == 'ordercolumns') { echo '
'; echo '

How to use the Custom Column Order function

'; echo '

Check the Customise Column Order box to enable custom ordering.

'; echo '

The Custom Order function allows you to define how your CSV data is structured per line so that it can be read correctly by the plugin. By default, the order of CSV values is: username, password, email, role, firstname, lastname, website.

'; echo '

Setting a custom order

'; echo '

The order you set in the Custom Order section should match exactly the order of your CSV data structure per line.

'; echo '

If your CSV data takes a different structure than the default, and maybe has additional data not required to be used for new registrations, for example:

'; echo '

email, state, username, role, lastname, firstname, phone, age

'; echo '

you can set the Custom Order appropriate to how the data should be read (left to right), using the "ignore" option to tell the program to skip a redundant data column. In this case, you would set up the Custom Column drop-boxes in this order:

'; echo '

email, ignore, username, role, lastname, firstname, ignore, ignore

'; echo '

Column actions

'; echo '

Each column in the Custom Order box also contains buttons for reordering, adding and deleting columns:

'; echo '
'; //show settings info } else if ($infotype == 'settings') { echo '
'; echo '

Information about Settings options

'; echo '
'; echo '

General Options

Send each new user a registration notification email?
If selected, automatically sends an email to each new registered user with the information provided in the Customise New User Notification Email settings. Users who have been added with a "forced" email address will not be emailed.

Send me a complete list of new user account details:
Highly recommended. When you submit the multiple registration form, the results of your registration will display on the screen. However, this information will not remain on the screen once you navigate away from the page or submit the form again. This option emails all this information to your registered WordPress user account email.

Validate entered email addresses:
This setting affects both the in-page validation and the on-submit validation. It uses WordPress "is_email" verification. If you have trouble entering email addresses that you believe are valid, disable this option.

Sanitize usernames using Strict method:
Determines whether usernames are sanitized with Strict method or not. Enabling this option disallows the use of many symbols that may be used in usernames normally. Affects both the on-screen validation and the on-submit validation. Get more info on user sanitization.

Force Fill empty email addresses:
Highly NOT recommended. This setting ignores empty email address fields that would normally cause that new user\'s registration to fail by creating a fake email address such as "temp_username@temp_username.fake". It is very much recommended that all new users have a valid email address, and this function should only be used in cases where you need to register new users that do not have active email accounts.

Ignore individual User Role settings and set all new users to this role:
Overrides any individual Role you select for each new and sets them to the role you choose here.

'; echo '

Customise New User Notification Email

From/Reply Address:
By default, new users will see the From/Reply email address in their New User Notification email as the email address of the administrator that added them. You can change this email address by adding a different address here, such as a "no reply" email address. You may also use this email address in the email message using the [fromreply] shortcode.

Site Login URL:
If you want to direct new users to a specific web address to log in, add the full URL here (including the http://). You may then add this to your email message using the [siteloginurl] shortcode. By default this setting is your main site URL.

Email Subject:
This is your email subject line and can include any of the shortcodes to add additional information to the subject line.

Email Message:
This is your main email content and must be written in HTML format using valid HTML tags (such as p and h1). Any HTML tag that can be understood by an email program can be used here. If you\'re not familiar with HTML markup, its probably best to stick to the default message, or you can play with it and use the Send Test Email button to send yourself an example notification email so you can check its formatting and content.

Shortcodes:
The shortcodes [sitename] [siteurl] [siteloginurl] [username] [password] [useremail] [fromreply] can be used in the Email Subject and Email Message fields to add specific data to your user notification email. For example, if you want to add that specific user\'s password to the email, using the [password] shortcode will add the users newly created password in there. Use these shortcodes to structure your email body text as you require.

Send Test Email:
Only available with Javascript enabled. This sends an example New User Notification Email to your email address using the information you currently have in the settings fields. Note that this does not save your Settings - you must still click the Save Options button to save your changes. This allows you to view the data and layout of the email that newly registered users will get when they are added to the site.

'; echo '
'; echo '
'; } } //end general info function //a call to action add_action( 'admin_menu', 'amu_menu' ); add_action( 'admin_print_styles', 'addmultiuser_style' ); add_action( 'admin_print_scripts', 'on_screen_validation' ); add_action( 'admin_print_scripts', 'multiadd_actions' ); add_action( 'wp_ajax_UserNameValidation', 'validateUserName' ); add_action( 'wp_ajax_EmailValidation', 'validateEmail' ); add_action( 'wp_ajax_OptionTestEmail', 'sendTestEmail' ); //activation/deactivation options register_activation_hook(__FILE__, 'set_default_options'); //validation functions function validateUserName() { $username = trim($_POST['thevars']); $sanstrict = $_POST['sanstrict']; if ($sanstrict == 'yes') { $sanUsername = sanitize_user( $username, true ); } else { $sanUsername = sanitize_user( $username, false ); } if ( username_exists( $sanUsername ) ) { echo 'exists'; } else { if ($sanUsername != $username) { echo 'badchars'; } else { echo 'spare'; } } exit; } function validateEmail() { $email = $_POST['thevars']; $shouldValidate = $_POST['isValidated']; if ($shouldValidate == 'yes') { if ( !is_email($email) ) { echo 'emailinvalid'; exit; } } if ( email_exists($email) ) { echo 'exists'; } else { echo 'spare'; } exit; } function sendTestEmail() { global $current_user, $wpdb; get_currentuserinfo(); //from site settings $thisBlogName = get_bloginfo('name'); $thisBlogUrl = site_url(); $test_adminmail = $current_user->user_email; //fabricated for testing $test_username = 'test_username'; $test_password = 'test_password'; //posted vars from ajax $test_fromreply = $_POST['test_email']; $test_loginurl = $_POST['test_loginurl']; $test_mailsubject = $_POST['test_mailhead']; $test_mailtext = $_POST['test_mailtext']; //replace instances of shortcodes $emailkeywords = array('[sitename]', '[siteurl]', '[siteloginurl]', '[username]', '[password]', '[useremail]', '[fromreply]'); $emailreplaces = array($thisBlogName, ''.$thisBlogUrl.'',''.$test_loginurl.'', $test_username, $test_password, $test_fromreply, $test_fromreply); $subject = str_replace($emailkeywords, $emailreplaces, $test_mailsubject); $message = str_replace($emailkeywords, $emailreplaces, $test_mailtext); //create valid header $headers = 'From: '.$test_fromreply.' <'.$test_fromreply.'>' . "\r\n"; //filter to create html email add_filter('wp_mail_content_type',create_function('', 'return "text/html"; ')); //send email wp_mail($test_adminmail, $subject, $message, $headers); exit; } ?>