How to import many users: Revision

Last updated by zyon

Here is a small import script that worked for me.

 

csv file (utf-8 encoded):

"name";"username";"email";"plaintextpassword"

 

<?php
    require_once('/var/www/htdocs/engine/start.php');
    global $CONFIG;
    $ordner = "/var/www/htdocs";
    $rb_datei = fopen($ordner."/user.csv", "r");
    if ($rb_datei) {
        $array = explode("\n", fread($rb_datei, filesize($ordner."/user.csv")));
    } 
    $total_array = count($array);
    echo $total_array;   
    $i = 0;       
    while($i < $total_array) {           
        $data = explode(";", $array[$i]);       
        $name = str_replace('"','',utf8_decode($data[1]));
        $username = str_replace('"','',utf8_decode($data[2]));
        $email = str_replace('"','',utf8_decode($data[3]));       
        $password = str_replace('"','',utf8_decode($data[4]));   
        $guid = register_user($username, $password, $name, $email, false);
        $user = get_entity($guid);   
        $user->enable();
        set_email_validation_status($user->getGUID(), true);       
        echo "<br>Username: ".$username." - Name: ".$name. " - E-Mail: ".$email. " - Password: ".$password;           
        $i++;
    }   
?>

History