1. Home
  2. Knowledge Base
  3. Uncanny LearnDash Toolkit Pro
  4. Import LearnDash Users

Overview

The Import LearnDash User module is part of the Pro Suite of modules for the Uncanny LearnDash Toolkit. This module lets you not only create new users in bulk but also add them to courses and LearnDash Groups, all from a CSV file. You can update existing users via CSV import too. Your users can be notified when their account is created or updated. This is a huge time-saving feature for those who need to manage a large number of users on their LearnDash site manually.

This is a complex module and we recommend starting by watching the YouTube video above in its entirety.

Here are some case scenarios when you might consider importing users from CSV:

  • Your site does not allow self-registration. You need to manually create a batch of new users at a time.
  • You create generic user accounts and recycle them. You need to reset user passwords before each new cycle.
  • You sell access to organizations. You need to set up a new LearnDash Group for each organization and quickly add their users to this new group.
  • You introduced a new course. A company bought access for their staff but they’re not all in groups. You need to add their users to this new course quickly.

Importing users involves a four-step process. It’s important that you review the instructions and download our sample CSV to see examples of the fields that can be included. We also recommend that you test your import with a small number of users first.

Step 1: Review Options

Use the Options tab to configure:

  • Whether to update or ignore users that already exist on your website
  • Role to assign to imported users
  • Course(s) to enroll imported users into
  • LearnDash Group(s) to assign imported users to

In order to apply the default role, course(s) and group(s) specified in Options, your CSV file must include the appropriate column headings (see Step 3 below). In other words, if you wanted to add all users in the upload file to a course selected in the UI, the learndash_courses column must be included in the CSV file and it would then be blank for all users.

Step 2: Review Email Settings

Use the Email Settings tab to:

  • Enable email notifications to new and/or updated users
  • Customize email templates

Here is an example of an email template with variables which will be replaced with specific account and site information when the email is sent to users.

pro_import_user_email_template

 

Note: If you enable Send Email but do not provide content for the subject or message, the default email template will be used. Also note that the message can contain HTML, and because it supports HTML your emails will not use an email template plugin (like WP Better Emails) if one is installed. To brand your emails consider pasting the email template HTML source into the Text view of the email editor.

Step 3: Create a CSV file

Your CSV file must be comma-delimited with a .csv extension. It requires user_login and user_email columns, and can include any number of optional meta fields below.

Column HeadingDescriptionRequired/Optional
user_loginThe user's usernameRequired
user_emailThe user's emailRequired
user_passThe user's passwordOptional
first_nameThe user's first nameOptional
last_nameThe user's last nameOptional
display_nameThe user's display nameOptional
wp_roleRole to assign to the imported user, specified by role slug. If this column exists and cell is empty, the role in Options will be used. Available role slugs for your site are listed in the Available Meta Fields table in the Instructions tab.Optional
learndash_coursesOne or more courses to enroll the user into, specified by course ID. If this column exists and cell is empty, course(s) in Options will be used. Multiple course IDs must be separated by semi-colons, e.g., 96;107;92Optional
learndash_groupsOne or more LearnDash groups to enroll the user into, specified by group ID. If this column exists and cell is empty, group(s) in Options will be used. Multiple group IDs must be separated by semi-colons, e.g., 91;102;98Optional

Notes:

  • Any column heading not recognized as a standard WordPress meta key will be created as a custom user meta key.
  • If you don’t include a wp_role column in your CSV, all imported users will get the subscriber role.
  • If no user_pass column or value is present for new users, a password will be auto-generated.
  • Username and email address cannot be updated via import.
  • Although you may specify any role to assign to imported users, keep in mind certain roles (e.g., Group Leader) require additional setup. We recommend that you use import for learners (subscribers) only.

Let’s take a look at an example in which the same CSV file is used to create new users and update existing users (if Update is selected in Options). The CSV file contains the following data:

user_login,user_email,user_pass,first_name,last_name,wp_role,learndash_courses,learndash_groups
amiller,amiller@mymail.com,test1234,Anne,Miller,,,
ajones,ajones@mymail.com,,Arthur,Jones,,,
aryans,aryans@mymail.com,,Annie,Ryans,,11;22,100;200

Suppose the first user, Anne Miller, is a new user. Her new account will be created with a manual password and the default role, course(s), and group(s) specified in Options.

Suppose the second user, Arthur Jones, is also a new user. Because the user_pass field is empty, his password will be auto-generated. He will be added to the default role, course(s), and group(s) specified in Options.

Suppose the third user, Annie Ryans, is an existing user. She will be enrolled into courses with IDs 11 and 22 as well as assigned the groups with IDs 100 and 200. There will be no change to her password.

Note that when you update existing users:

  • If you leave their first name and/or last name empty, the user’s existing meta value will be replaced with the blank value.
  • The course(s) and group(s) you specify in the CSV will be added to what’s already in the user’s profile rather than replacing them.

Step 4: Import Users

Go to the Import Users tab once your CSV file is ready to begin the import.

The Current Settings section shows you what has been configured in Options and Email Settings. Review these settings and make any changes as necessary.

import_users

When you are ready, proceed to the Import LearnDash Users section to upload your CSV file.

import_learndash_users

The validation results will show you any potential problems with the import. (The example below shows that one of the users has a malformed email address.)

importusers_validationresults

Make any necessary corrections to your CSV file and re-upload it, or click on Perform Import to proceed with import.

importusers_performimport

When import is complete, the page will refresh and confirm the number of users that have been successfully created/updated. Please note the first validation is a quick check. It may not always coincide with the final upload results which may report other conflicts such as mismatched usernames and email addresses.

Tips

Version 2.0.5 of the plugin and later support customization of the import process to allow more flexibility in setting values like Display Name (which cannot be upload as a column). Here’s an example of a code snippet that could be used in a functions.php file to set Display Name equal to First Name and Last Name as part of the import:

add_filter('csv_wp_insert_user', 'uo_kb_insert_filter', 10, 2);
function uo_kb_insert_filter( $userdata, $current_row ){

   // $user_data give you an array of fields that can be a passed into the wp_insert_user function
   /*
    * ex.
    *
   $userdata = array(
       'user_email'  =>  'aflinch@example.com',
       'user_login'  =>  'aflinch',
       'user_pass'   =>  '4rV4Z1lQ9Jeg'
   );
    */

   // Add dsiplay name to user data as the first_name and last_name in the CSV row
   // ex. ["aflinch","aflinch@example.com","Adrian","Flinch","4rV4Z1lQ9Jeg","subscriber"]
   //         0              1                2         3          4             5
   // You will have to find out the index of the CSV cell
   $userdata['display_name'] = $current_row[2] . ' ' . $current_row[3];

   return $userdata;
}

 

Was this article helpful?

13 replies
    • Ryan
      Ryan says:

      Hi Manny,

      Our Groups plugin has a very limited version of the CSV user upload function, but I’m afraid this particular module is restricted to admins only. In the hands of Group Leaders it would be very dangerous and confusing, unless we modified it heavily to only support groups and courses associated with the Group Leader’s access. Even then, we would probably need to restrict email capabilities.

      We know there is value in adding more options like this for Group Leaders, like some level of customization for welcome emails, but I’m afraid that for now this remains an admin only module.

      Reply
      • Anfield
        Anfield says:

        Hi Ryan,
        We have a multisite WP and our site level admin cannot view the import user page. How to I let our site level admin to do the importing task? Thanks.

        Reply
        • Ken Young
          Ken Young says:

          Unfortunately, it looks like the Import LearnDash Users module is currently incompatible with multisite installations. We’re looking into whether we can add support in the next release. I’ll update here when we’re able to make that determination.

          Reply
    • Ken Young
      Ken Young says:

      To force the user reset their password, you can remove the %Password% token from the email and instead instruct them to follow a link to the password reset page on your site.

      Reply
  1. Ariel
    Ariel says:

    can you automatically set users to ‘completed’ status when importing? For example if you are moving to learndash from a different platform and want your users who have already completed the course to also have access to the new LD course but don’t want them to have to go through and complete all modules again. thanks!

    Reply
    • Ken Young
      Ken Young says:

      You can get the group ID by going to LearnDash LMS > Groups, clicking on a group, then looking at the URL in your browser. It should contain something like “?post=2011”. That number is the Group ID.

      Reply
  2. petest
    petest says:

    Hi,

    I downloaded the sample csv.
    Then i put text to columns, make some changes and save as csv.
    i get an error when oploading that i do not have the required email field.
    Thats because my csv is not seperated with , but with ;
    How can i change this setting?
    Because in your video you can upload the file with the csv set to columns.
    I do not want my client to do al lot of unnecesary steps of find and replacing all ; with , and then paste in the first column.

    Kind regards.

    Reply
    • Ryan
      Ryan says:

      This issue, where the delimiter is something other than a comma, is usually caused by the language settings on your computer and you use Excel to create the file. Changing your language settings is one option, or you might try importing the file into Google Sheets instead where it’s easier to export using a commas as the delimiter.

      Reply

Comments/Questions

Please note that this is not an official support channel and questions/comments may go unanswered.
To request support, log in to your account and click Submit a Request.

Leave a Reply

Your email address will not be published. Required fields are marked *