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.1', $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 may now log into the site at [siteloginurl]
Your username is [username] and your password is [password]
Regards,
[sitename] Admin
[siteurl]
'; //update options update_option( 'amu_usernotify', 'yes' ); update_option( 'amu_confirmation', 'yes' ); update_option( 'amu_setallroles', 'notset' ); update_option( 'amu_validatestrict', 'no' ); update_option( 'amu_validatemail', 'yes' ); update_option( 'amu_forcefill', 'no' ); update_option( 'amu_defadminemail', $defaultAdminEmail ); update_option( 'amu_siteloginurl', $sitelogurl ); update_option( 'amu_useremailhead', $defaultUserEmailHead ); update_option( 'amu_useremailtext', $defaultUserEmailText ); } //coming in 1.2.3 //function amu_networksite() { // if (!current_user_can('manage_network') ) { // wp_die( __('You do not have sufficient permissions to access this page.') ); // } //} //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.') ); } //when accessing amu, set options if they don't exist if(!get_option('amu_usernotify')) { set_default_options(); } //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'); //begin wrap class echo 'Settings have been saved.
'; echo 'Settings have been reset.
'; echo 'New User User Accounts Processed.
'; 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.
User '.$user_details->user_login.' has been sent a confirmation email.
'; } else { $user_details = get_userdata($i); //process user addition if($allExistingToRole == 'notset') { add_existing_user_to_blog( array( 'user_id' => $i, 'role' => $_POST['setrole_'.$i] ) ); } else { add_existing_user_to_blog( array( 'user_id' => $i, 'role' => $_POST['existingToRole'] ) ); } //notification line echo 'User '.$user_details->user_login.' has been added to the site.
'; } } } 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 '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","TXT","csv","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']); $linecount = count(file($_FILES['csvuploader']['tmp_name'])); echo 'The following user information has been extracted from your uploaded file. Total entries found in this document: '.$linecount.'
'; 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 'Click the Create User Information Form button below to convert this user information into a form to customise specific information. Alternatively, choose the Skip Form and Add Users option if you want to immediately add the users (duplicate entries will be skipped if they are found).
'; echo 'Important: If you are adding more than 100 users in one pass, it is recommended you use the Skip option, as you will likely exceed your PHP memory limit. Please see the information at the bottom of the screen for more info.
'; echo '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); showMemLimitInfo(); } } //process into form if ( isset($_POST['formshow_csvprocess'] ) ) { $file = $_POST['filecontents']; $pasteddata = parse_csv($file); $data_rev = reorder_csv($pasteddata); $counter = 0; 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 '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 '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 'Error: No valid email addresses were found in your input data! Please try again.
'; addByEmailList($emailListError); } else { //SUCCESS 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 '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 'Select the users you wish to add to this site from your Network Users list and click the Add All Users button.
'; echo 'Only users from your Network that are not already added to this site will appear in the list below.
'; echo 'Please enter the number of users you wish to add and press the Create Blank Form button. It is recommended you stay under 500 so as to avoid exceeding PHP memory limit.
'; echo 'You don\'t have to be too specific. You can add more as you go.
'; 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 'Click the Create User Information Form button below to convert this user information into a form to customise specific information. Alternatively, choose the Skip Form and Add Users option if you want to immediately add the users (duplicate entries will be skipped if they are found).
'; echo 'Important: If you are adding more than 100 users in one pass, it is recommended you use the Skip option, as you will likely exceed your PHP memory limit. Please see the information at the bottom of the screen for more info.
'; 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 'Click the Create User Information Form button below to convert this user information into a form to customise specific information. Alternatively, choose the Skip Form and Add Users option if you want to immediately add the users (duplicate entries will be skipped if they are found).
'; echo 'Important: If you are adding more than 100 users in one pass, it is recommended you use the Skip option, as you will likely exceed your PHP memory limit. Please see the information at the bottom of the screen for more info.
'; 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 '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 '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 'Adding an exceptionally high number of users at any time is possible, however in the case of adding hundred or even thousands of users at a time, depending on your server capacity, you may have to modify your wp-config file to turn off the time limit that can cause the adding function to time out before it is complete. Further information can be found on the plugin page at http://www.happynuclear.com/sandbox/amu/add-multiple-users-for-wordpress.php.
'; 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 '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 '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 '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. 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.
Please choose either a .csv or .txt file to upload. All other file types are disallowed.
'; 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 '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 '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 'On this page you will see a list of users taken from your Network list who are NOT already a part of this site. Firstly, set the two options as desired above the user list. You may then check the users you wish to add to this site and click the Add All Users button.
'; echo 'Ignore individual roles and set all selected users to this role:
You can assign each existing user you add to this site an individual Role within this site. Make a selection here if you want to add all existing users you choose with the Role defined here instead.
Send each user a confimation email:
If you leave this unchecked, users you select will be automatically added to this site. Check this option if you do not want this to happen. Instead, each user you select will be sent an email asking them to confirm their adding to this site. When they have confirmed, they will show up in the Users list for this site.
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 '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 'Each column in the Custom Order box also contains buttons for reordering, adding and deleting columns:
'; echo '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.
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.
If you are using this function to add more than 100 users it is recommended that you use the Skip button. This function bypasses the Form option, which displays each new user on a separate line, as it can cause issues with memory usage at high volumes. With the skip option you lose the ability to customise user information before adding your users, but it is more stable when adding many users.
'; echo 'Note:In the case of adding hundred or even thousands of users at a time, depending on your server capacity, you may have to modify your wp-config file to turn off the time limit that can cause the adding function to time out before it is complete. Further information can be found on the plugin page at http://www.happynuclear.com/sandbox/amu/add-multiple-users-for-wordpress.php.
'; echo 'Please refer to the Information about Network options at the bottom of this page for more information about these settings.
'; // echo 'Please refer to the Information about Settings options at the bottom of this page for more information about these settings.
'; 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 '