How to add a user to main site with Batch Create?

Trying to add a group of users to the main site on my multisite install. What is the site slug of the main site? I've tried leaving it blank, putting "/" and the url of the main site but nothing works.

I saw this thread but it was never clearly answered:

  • Michael Bissett
    • Recruit

    Hey @Daniel, hope you're doing well today! :slight_smile:

    Have you tried entering "null" (without quotes) into the "Site Name" field, and you then entering the name of your main site in the "Site Title" field?

    (in the example .csv file, the "Site Name" is set to to "demoblogname1", and the "Site Title" is set to "Demo Blog Title 1")

    Please advise,

  • Daniel
    • New Recruit

    Ya null gets the user assigned to no site. What I've tried is entering the "/" without the "" included. I've tried leaving the Site Name blank but I get an error saying "No Data was retrieved from file". I've tried entering the url of the site "" without the "" and that didn't work either, said in the log file "Missing or invalid site address". I've also tried entering the domain name without .com and that added a new site named "domain" which is not what I want.

  • Daniel
    • New Recruit

    Hello @Ashok, thanks for responding and testing out. Based on previous track record from developer, any idea how long this fix will take? I was planning on using the Batch Create plugin to import a bunch of new users this weekend for a project. I obviously can't do that with the current state of the plugin. Let me know if I need to pursue a refund and find a different alternative.

    Thanks! Appreciate your help!

  • Jose
    • Bruno Diaz

    Hey there @Daniel,

    Hope you are doing great today :slight_smile:

    It seems that the plugin was not aimed to work on the main site, so I'm not sure if this is actually a bug or a feature request.

    In any case, I just made a customization for you that I'm attaching here.

    The empty/null field may cause some issues, so I decided to just use the reserved name 'main' for the main blog.

    Once you install the custom version, you just need to use something like this to create a new user in the main blog:

    If by any chance, the name 'main' needs to be used in a sub-site, then no worries, you can change the reserved name to whatever you want by just adding this in your wp-config.php:
    define('INCSUB_BATCH_MAIN_BLOG_NAME', 'some-name');

    Please let me know if this works as expected. :slight_smile:


  • Daniel
    • New Recruit

    Hey @Jose,

    Thanks, that worked! Its hard to believe that the plugin was only made to work for sub sites and not the main site. Hopefully its something that will be added to the core of the plugin.

    Out of curiosity in wanting to learn, where in the plugin did you do some modifications to make this work? I'd love to learn from what you did. Appreciate your help!

  • Jose
    • Bruno Diaz

    Hey @Daniel,

    Glad it worked!

    The change was quite simple actually. It was most the time that it took to read the code and figure where to make the cut. :slight_smile:

    In the file wp-content/plugins/batch-create/batch-create.php I added the constant that will hold the reserved name for the main site:

                define('INCSUB_BATCH_MAIN_BLOG_NAME', 'main');

    You should notice that it checks first if the constant is already defined. This is to allow the value to be set in wp-config.php.

    Then, in the file wp-content/plugins/batch-create/inc/creator.php, where the parsing magic happens, I just added an exception for the blog ID detection.

    It was doing this:
    $blog_id = get_id_from_blogname( $domain );

    And I changed to this:

    if($domain == INCSUB_BATCH_MAIN_BLOG_NAME){
          $blog_id = 1;
     } else {
          $blog_id = get_id_from_blogname( $domain );

    Let me know if you have any other question and I'll be happy to answer. :slight_smile:


  • Ignacio
    • HummingBird

    Hi @Daniel.

    We just released a new version of the plugin. Now it allows blog IDs and not only domains in CSV/XLS files. So if you want to add a user to your main blog just set the Blog domain field to 1.

    Could you upgrade, test and advice?


Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.