A simple function to import users from a CSV file into WordPress. Also has the ability to add the imported users to a group by group name. If applicable you can add as many custom meta data columns as you want by modifying the function.
Note: the function will ignore the first row so you can safely leave your column headings in the csv file.
- Custom Meta Data Columns: phone, fax
- Group Column: group
role,email,first_name,last_name,title,phone,fax,group
author,john.doe@gmail.com,John,Doe,Employee,5555555555,5555555555,ACME Employees
The function has the ability to add custom meta data to users ready to use by uncommenting the respective lines in the function.
Group import is for itthinx Groups plugin. https://wordpress.org/plugins/groups/
Just uncomment the respective lines in the function to import the users into the group and list the group name in the CSV file.
- Upload your properly formatted CSV file to your active theme directory.
- Add the function to your theme's
functions.php
file. - Adjust the file name.
- Uncomment optional features (custom meta data, group insertion)
- Uncomment the function call at the bottom
- Load any page while logged in as super admin.
Once you are done, be sure to remove or recomment the function call as it will slow the site down while running and throw errors once the users have been imported.