I need a way to massively add users and I would like to use alt_login. I can do it without installing it (see code below), but I don't know how to do it with alt_login. Can anybody help me?

thanks

// some bucle

          $args = array(
           'mail' => $afiliat_email,
           'pass' => "****",
           'name' => $afiliat_dni,
           'status' => 1,
         );
         $account = user_save( $account, $args);

      //Personal info go into profiles into Personal_info category
       $personal_info = array(
          'profile_nom' => $afiliat_nom." ".$afiliat_cognoms,
          'profile_ambit' => $ambit,
          'profile_dni' => $afiliat_dni,
          'profile_funcio' => $funcio,
          'profile_telefon' => eregi_replace('[^0-9]', '',$afiliat_telefon),
          'profile_mobil' => eregi_replace('[^0-9]', '',$afiliat_mobil),
          'profile_adreca' => $afiliat_adreca,
          'profile_cp' => $afiliat_codi_postal,
          'profile_poblacio' => $poblacio_nom,
          'profile_data_naixement' => $afiliat_data_naixement,
       );
       user_save($account, $personal_info, 'Afiliació');



// end bucle

Comments

michelle’s picture

I deleted the other issues. Please don't file identical issues 10 times. That won't make it be addressed any quicker.

Michelle

hunmonk’s picture

Project: Alternative login ID & display names » User Import
Version: 5.x-1.6 » 5.x-1.2-beta

this is not a job for alt_login. reassigning the issue to a more appropriate module.

enboig’s picture

First of all sorry for all the submints, my browser sent me an error so I pushed refresh without checking if the post was created (I write that in one of the deleted post)

Secondly, I have created a module to create users (I didn't know about the "import users" module...) and I want to know how to integrate that in alt_login. Is there a way of saving the alternative name using "user_save()" or something similar?

I will create users who I want to enter using a personal identification number (here is where alt_login comes), then allow them to change their username (by default their name and a random number), but I will need to be able to track them (I was thinking of tracking them using alt_login).

I have read the code and maybe using:
_alt_login_update($user->uid, $edit);
or
db_query("UPDATE {alt_login} SET alt_login = '%s' WHERE uid = %d", $alt_login, $uid);
geting the $uid from the $account variable in my code....

enboig’s picture

Status: Active » Closed (fixed)

Just in case somebody needs to do the same as me, after adding the user I added its alt_login with this:

if (db_result(db_query('SELECT uid FROM {alt_login} WHERE uid = %d', $account->uid))) 
  db_query("UPDATE {alt_login} SET alt_login = '%s' WHERE uid = %d", $unique_alt_login, $account->uid);
else
 db_query("INSERT INTO {alt_login} (uid, alt_login) VALUES (%d, '%s')", $account->uid, $unique_alt_login);

thanks for your time.