Import users from a CSV file into WordPress
|Author:||Thomas Sjolshagen (profile at wordpress.org)|
|WordPress version required:||4.4|
|WordPress version tested:||4.9.8|
|Added to WordPress repository:||03-01-2018|
|Total downloads:||1 840|
Click to start download
How to use?
Click on the ‘Import Members’ link in the ‘Membership’ menu, then select your CSV file.
Next you have to decide whether you:
- want to deactivate previously existing member record(s) for the user – The CSV record has to specify the same membership as the user previously had so this is most useful when having to reimport/update data (default: enabled and recommended),
- update the existing user/member’s information (default: enabled and recommended)
- send a notification email to new users (default: disabled),
- want the password nag to be displayed when the user logs in (default: disabled),
- have included a hashed (encoded) password specified in the import file and (default: disabled)
- want to use the background import option (default: enabled and recommended)
- create a PMPro order record based on supplied payment info in the .csv file (default: disabled)
Then click the ‘Import’ button.
Each row in your CSV file should represent a user; each column identifies user data, user meta data or user membership data
If a column name matches a field in the user table, data from this column is imported in that field; if not, data is imported in a user meta field with the name of the column or into the PMPro custom membership tables.
Look at the examples/import.csv file in the plugin directory (also linked on the “Import Members” page) to have a better understanding of how the your CSV file should be organized and what the data fields need to contain as far as formatting/values go.
You can always try importing the examples/import.csv file and look at the result, assuming the values specified for the membership_id in the example file match your membership level configuration.
The .CSV file from the “Export to CSV” button on the “Members List” page won’t import?
The purpose of the resulting .CSV file from the “Export to CSV” is to generate reports that are meaningful to a human, not a file that can be imported easily. This is true for any of the available Import from .CSV plugins/add-ons for Paid Memberships Pro.
Basically there are a few key differences between the file resulting from the Export function and the file contents needed to import the same member.
As of version 2.5, this plugin includes data checks for some of the more common mistakes I’ve seen in the .CSV file(s).
You should also check out the import example file that is linked on the “Import Members” page (under the “Choose File” button).
My import fails, what is wrong?
This is almost always related to the data in the file being imported. As a result, I’ve added some data tests for some of the typical mistakes I’ve seen in the .CSV file(s) being imported. There is also a link to an example file on the “Import Members” page (under the “Choose File” button) that illustrates a functional import file. Things lik what the field names are and the format you’ll most likely need to use for the data in that column.
Check the wp-content/uploads/pmp_im_errors.log log file for details on the import operations (link should also be included in a wp-admin dashboard notice if there are errors/warnings). The log should contain suggestions on some of the more common mistakes in the data being imported.
Do I need to include all the columns from the sample file?
No. Only include the columns where you have data to import. I.e, if none of your members need to have their membership end date defined (i.e the membership you’re importing doesn’t have an expiration or it’s a recurring membership with a linked Payment Gateway subscription plan), just remove the column(s) you don’t need. That way, the plugin doesn’t try to import data that isn’t there.
If a column has no data, you should remove the column and it’s column header from the import file!
The plugin didn’t import any membership data!?!
This is a pretty common question and the reason is almost always because there is something unexpected in the
membership_ portion of the row being imported.
Most often it’s the date/time format for the membership_startdate and membership_enddate columns.
If you use MS Excel(tm) to prepare your .CSV file, you’re in for a treat…
In my experience, MS Excel(tm) is really good at changing the date format in a spreadsheet column to whatever it thinks works best (i.e. human readable).
However, human readable is often problematic for CSV imports, so you have to ensure the format follows the YYYY-MM-DD HH:ii:ss (where ii = 2 digit minute value). For startdate I’d recommend using
00:00:00 and for the enddate I’d suggest using
Just to be clear: The only date format for the membership_startdate, membership_enddate and the user_registered columns that this plugin will accept is the MySQL datetime format: YYYY-MM-DD HH:ii:ss.
Use anything else and your membership data will not be imported!
You can change the way Microsoft Excel(tm) handles date and time data in the Regional settings, but I’ve yet to figure out what the ideal settings are here. Truth be told, I’m using Apple Numbers and others have had great success using Google Sheets to process and export their .CSV files. Because there are alternatives to Microsoft Excel(tm) and they seem to work a lot better for this specific task, I’m not at all inclined to spend more time on fixing something that I view to be a rather significant “bug” in Excel(tm).
 = Being that it’s an intentional usability feature, I realize Microsoft is unlikely to be all that interested in fixing this “as designed” capability they’ve implemented.
Can this plugin be used to link sponsored members with their sponsors?
In version 2.60, we added support for importing Sponsors and their sponsored members. So, if you have the PMPro Sponsored Members add-on installed, active and need to link sponsors and their sponsored members during the import with this plugin.
- ENHANCEMENT: Add support for PMPro Sponsored Members import
- ENHANCEMENT: Add documentation for the Sponsored Members import to the FAQ section
- ENHANCEMENT: Add ‘Reset log’ button to let admin clear the Import Error/Warning log
- ENHANCEMENT: Add ‘View log’ button to let admin see the Import Error/Warning log
- ENHANCEMENT: Even more clear in the FAQ that importing credit card numbers is a dangerous thing to do (can be costly!)
- ENHANCEMENT: Updated import.csv example file with correct Sponsored Member column names
- ENHANCEMENT: Refactored Import_Members_From_CSV class
- BUG FIX: Didn’t trigger cleanup AJAX job when clicking the “Complete” button
- BUG FIX: Fatal error if importing when sponsored members add-on is active
ENHANCEMENT: Add warning banner in /wp-admin/ when wanting to send the ‘imported_welcome.html’ email but didn’t set the ‘membership_status’ column to ‘active’
ENHANCEMENT: Modify # of attempted records to import per iteration when wanting to send the imported_welcome.html email and/or creating an order record
ENHANCEMENT: Added ‘calculate_max_records’ method & using it in load_settings(), not the constructor
ENHANCEMENT: Allow editing imported_member.html in the Email Templates Admin add-on
ENHANCEMENT: Include imported_member template in the Email Template Admin add-on
BUG FIX: Don’t send the imported_welcome.html message if the record is configured as ‘inactive’
BUG FIX: Use paypal.me link for donations
BUG FIX: No Warning if we chose not to send the imported_welcome.html message due to configuration
BUG FIX: Would try to cancel subscription plans when updating existing membership level at import
BUG FIX: Loading imported_welcome message body by ‘pmp_im_imported_member_message_body’ filter would sometimes get overridden.
BUG FIX: Now running body through ‘pmp_im_imported_member_message_body’ after loading it
BUG FIX: Renamed plugin slightly to match branding rules
- BUG FIX: Import data would be cleared if the “Import Users from CSV Integraion” add-on is installed and active.
- ENHANCEMENT: Add more tests & info about incorrect user_registered, membership_startdate and membership_enddate date formats
- ENHANCEMENT: Display a WordPress notice (error) message if a bad/incorrect date format is used in the import file
- ENHANCEMENT: Display proposed solution for date format issues
- ENHANCEMENT: Added check for valid – pre-defined – membership ID for the user/row
- ENHANCEMENT: When “Add order” is selected and there are
pmpro_bprefixed columns with data in the row, use it to try and populate the MemberOrder billing info (in the order record)
- ENHANCEMENT: New and updated Frequently Asked Questions (FAQs)
- ENHANCEMENT: Slightly less stringent behavior if the subscription_transaction_id and/or the payment_transaction_id data is missing
- ENHANCEMENT: Verify that the current line/column count matches the # of header columns
- BUG FIX: Invalid import.csv example file
- BUG FIX: Didn’t always track error status
- BUG FIX: Didn’t handle membership ID values of 0 properly
- BUG FIX: Didn’t set the payment gateway for an order when different from the default was specified
- BUG FIX: Occasional “Fatal Error” during import operation
- ENHANCEMENT: Dedicated data check method with filterable result (allow 3rd party data checks w/returned result: ‘pmpro_import_members_from_csv_data_check_status’ ). Triggered for each record/row being imported.
- ENHANCEMENT: Disallow problematic file names when selecting import .csv file (files that will be modified during data sanitation on transfer)
- ENHANCEMENT: Various additional tests of data and corresponding error messages when attempting to import order data
- ENHANCEMENT: Can add a PMPro Order record for the imported user, even without a linked payment gateway record. This assumes that either the membership_initial_payment or membership_billing_amount column is present in the import (.CSV) file. The add order operation can also use the default Membership level definition pricing if neither are present in import file).
- ENHANCEMENT: Support most of the table fields for the pmpro_membership_orders and pmpro_memberships_users table with a ‘membership_’ prefix as importable data (pmpro_membership_orders data expects the ‘Add order’ option to be enabled/checked).
- ENHANCEMENT: Extract column names dynamically from PMPro’s custom membership users/orders tables
- ENHANCEMENT: Updated screenshot(s)
- ENHANCEMENT: Updated and added to FAQ section
- BUG FIX: Not loading/updating record if user exists and the only user identifiable data is the email address
- BUG FIX: Consistent use of quote characters in .js file
- BUG FIX: Incorrect ID(s) for NONCE(s)
- BUG FIX: Hardened the error/warning message logger
- BUG FIX: Plugin links were missing
- BUG FIX: Missing semi-colon terminations in some instances
- ENHANCEMENT: Added Donation button (with logic to not always display it) and request for reviews (with .css file)
- ENHANCEMENT: Clicking the Donation button will attempt to dismiss the donation nag for 2 months by trying to track the user’s client IP address (can be error prone in certain environments).
- ENHANCEMENT: Remove nag tracking when plugin is being deactivated
- ENHANCEMENT: Add styling for Import Members from a CSV file page
- ENHANCEMENT: More info when we think the import file isn’t found/located
- ENHANCEMENT: Open the example import file in its own browser window/tab
- ENHANCEMENT: Add user_login check (validity/duplication)
- ENHANCEMENT: Optionally suppress the “Your password was changed” and “Your email address was changed” message to member when updating their record
- ENHANCEMENT: Remove import file & options when user clicks “Finish” for the import
- ENHANCEMENT: Faster turnaround when triggering background loading
- ENHANCEMENT: Updated .pot file
- BUG FIX: Didn’t skip user_login based search if user found by email address
- BUG FIX: Would look up user by username before using the (more likely to be unique) email address
- BUG FIX: Would attempt to update a user record when we shouldn’t
- BUG FIX: Didn’t list all tracked/saved errors when import fails
- ENHANCEMENT: Clear output buffer before sending AJAX response
- ENHANCEMENT/FIX: Limiting max # of records per import iteration to <= 60
- ENHANCEMENT: More descriptive language for some error messages
- ENHANCEMENT: More checks during Import page load if on WPMU site(s)
- ENHANCEMENT: Split out different membership ID related error messages
- BUG FIX: Didn’t handle ‘inactive’ status when no membership_enddate is supplied
- BUG FIX: Didn’t always generate a log entry for certain errors/issues
- ENHANCEMENT: Warn if user has an invalid (non-existing) membership ID
- ENHANCEMENT: Warn if the user has an enddate in the future but have had their membership_status set to ‘inactive’
- ENHANCEMENT: Use ‘admin_cancelled’ as new status for preexisting user_id/membership_id records where status is ‘active’
- ENHANCEMENT: Various updates to the FAQ section.
- ENHANCEMENT/FIX: Better warning messages & handling of WP Multisite configurations
- BUG FIX: Only set status if explicitly asked to
- BUG FIX: Incorrect handling of UTF BOM characters led to missing 1st column header
- BUG FIX: Didn’t return new member record to update status for in all cases
- BUG FIX: Didn’t set the supplied membership_status value correctly in all cases
- BUG FIX: Didn’t set format for DB record update
- BUG FIX: Didn’t send imported_member.html message (when activated) to imported member
BUG FIX: Didn’t send the email template based welcome message
BUG FIX: Typo in warning/error messages
BUG FIX: A little too silent when the imported file is mis-configured
BUG FIX: MS Excel causing trouble w/first column import values (Improved UTF BOM handling)
BUG FIX: validate_date() method triggered PHP Notices in certain situations
BUG FIX: Improved checking of email field in import file
BUG FIX: Would sometimes trigger PHP Warning due to incorrectly loaded empty line of text
ENHANCEMENT: Strip the UTF BOM character if necessary from first/header line in import file
ENHANCEMENT: Clean up unneeded user metadata
ENHANCEMENT: Improved error logging/handling for typical import file errors
ENHANCEMENT: Send Welcome Email template when adding user to membership level (“Welcome imported user” email located in emails/ directory)
ENHANCEMENT: Add warning if unable to apply new membership level for user
ENHANCEMENT: Added method to load custom imported_member.html email template for Active Theme/Active Child Theme directory
ENHANCEMENT: Add settings for Sending WordPress new user/updated user message
ENHANCEMENT: Add setting for sending Custom Welcome Message for new/updated members (imported members)
ENHANCEMENT: Run cleanup of imported_ usermeta attributes after import is complete
- BUG FIX: Attempting to fix issue with the New User Notice not always being sent
- ENHANCEMENT: Select target recipients of “New User Notice” (User, Admin or both)
- BUG FIX: Didn’t include the transaction IDs, affiliate ID or gateway settings in the import
- BUG FIX: Typo in readme.txt
- ENHANCEMENT: Now calculating # of records to import in background based on PHP setting for max_execution_time
- ENHANCEMENT: Differentiate between warnings and errors. Errors should terminate execution. Warnings should be logged, but not end import.
- ENHANCEMENT: Added (‘Recommended’) for Import settings we recommend you use
- ENHANCEMENT: Improved error/warning reporting by using SplFileObject() to manage import file (indicates the line in the .csv file with a problem)
- ENHANCEMENT: Added error message when the ID, user_login and user_email columns are missing
- ENHANCEMENT: Added file indexed warning message if user_login has to be generated from the record email address (using front of ‘@’ as the login name)
- ENHANCEMENT: Added file indexed warning message when an email address is either missing or unrecognizable
- ENHANCEMENT: Include warning and error messages in Import status window (when applicable)
- ENHANCEMENT: Updated links to the WordPress.org repository for information and support for the plugin
- ENHANCEMENT: Linted and refactored the source files
- ENHANCEMENT: Expanded the FAQ section, fixed a few typos and updated the Change log in readme.txt
- BUG FIX: Better handling/reporting of unexpected values in the membership_status column, incorrect email formats, incorrect or missing membership_id value(s), improper date formats for the membership_startdate, membership_enddate and membership_timestamp columns and unexpected membership configurations (based on values supplied in the import file)
- BUG FIX: Displaying error/warning/info messages in wp-admin was a little flaky
- BUG FIX: Would allow duplication of error messages in wp-admin area
- ENHANCEMENT: Added error checking and messages to warn about the most common PMPro related errors in the .csv file being imported.
- ENHANCEMENT: Added function to test dates for compliance with MySQL requirements
- BUG FIX: Typo in add_action( ‘pmp_im_pre_user_import’ …) caused default pre-import action to not be triggered
- ENHANCEMENT/FIX: Updated action names: ‘pmp_im_post_member_import’, ‘pmp_im_pre_members_import’
- BUG FIX: PHP Warning
- BUG FIX: The resume URL didn’t work as expected
- BUG FIX: Didn’t set the blog ID when updating membership info
- BUG FIX: Didn’t cancel previous membership records for the imported user ID / membership ID combination when deactivate_old_memberships was set to true (checked)
- ENHANCEMENT: Renamed import page function (documentation related)
- ENHANCEMENT: Added link to error log (if applicable) to the admin notices
- ENHANCEMENT: Add support for WP Multi Site configurations (adding/updating users to the specified WPMU site)
- ENHANCEMENT: Better error handling/notifications
- BUG FIX: Didn’t preserve settings between loads of JS
- BUG FIX: Didn’t always load the correct settings for the JS based import
- BUG FIX: Include error info
- BUG FIX: Didn’t include all required settings in AJAX operation
- BUG FIX: Didn’t set and clear busy icon for import status text
- ENHANCEMENT/FIX: Use PMPro variable array to set record info for each user
- ENHANCEMENT/FIX: Renamed methods to better describe where they’re being used/what they’re used for
- ENHANCEMENT: Action handler when clicking the “Finished” button at end of import ( redirect to admin_url() )
- ENHANCEMENT: Add set_busy() and clear_busy() for feedback during import
- ENHANCEMENT: Add “Finished” button (display when import is complete)
- ENHANCEMENT: Reorder options (more logical, I think)
- ENHANCEMENT: Use AJAX import as default behavior
- ENHANCEMENT: Add “Import Members” to “Memberships” drop-down menu in /wp-admin/
- ENHANCEMENT: Improved prompts/info for options on import page
- ENHANCEMENT: Load plugin actions in plugins_loaded action
- ENHANCEMENT: Fixing PHPDoc for new functions/updated functions
- ENHANCEMENT: Variable name update
- ENHANCEMENT: Clean up insert method for hashed passwords
- ENHANCEMENT: Log error message if there’s a problem with a header field
- ENHANCEMENT: Adding screenshot images
- Fixed bug: Sanitizing request variables
- Fixed bug: Notification nag not getting configured correctly
- Fixed bug: New user notification not getting configured correctly
- Fixed bug: Didn’t always handle pause/resume (at all)
- Fixed bug: Didn’t stop/pause the import when user clicked the “pause” link
- Enhancement: Added
is_iu_import_records_per_scanfilter to let user set # of records to import per step when using JS import
- Enhancement: Refactored and added local scope for variables & functions
- Enhancement: Use JSON and status returns from server
- Enhancement: Use filter to set timeout for AJAX operation
- Enhancement: Use proper WP AJAX functionality for variables and statuses
- Enhancement: Clean up translations and grammar.
- Enhancement: Use printf()/sprintf() to improve formatting & translation
- Enhancement: Clean up REQUEST variable use
- Enhancement: Allow setting password nag for both new and updated accounts
- Enhancement: Use wp_send_json*() functions for AJAX actions
- Enhancement: Allow import of pre-hashed passwords for user records
- Enhancement: More reliable option based tracking of imports (not transients)
- Forked from the Import Users from CSV plugin and integrated the “PMPro Import Users From CSV Integration” add-on functionality
- Fixed bug with Notification Nag
- Fixed bug with user notification
- Fixed bugs with static/non-static function calls