Skip to: site menu |main content

Welcome to my personal site. If You have any question or suggestion please feel free to contact me from contact page.

Advertisements

Contact me to place your Ads Here..

Powered by Drupal, an open source content management system

Syndicate

Syndicate content

Drupal User import user_save and profile fields How to import users into Drupal

Basic Idea behind importing user in drupal is:-
1)Create dummy user object...
2)Call drupal's user_save function...

Actually, You need to create the user account array first...and then pass it to function user_save().

<?php
//$account = user_save('',$user_array);

     
$password = user_password($your_password);
     
$user = array(
       
'name' => $username,// Whatever you have
       
'pass' => $password,//Encr
       
'mail' => $email,//Your email here in variable
        //'roles' => array( 3 => 3 ),//Add some role ID if you have and uncomment it if any
       
'status' => 1,// By default make users active
     
);
     
$account = user_save('', $account);// Call user_save function
     
watchdog(
           
'user',
           
'New user: %name (%email).',
            array(
'%name' => $username, '%email' => $email),
           
WATCHDOG_NOTICE,
           
l(t('edit'), 'user/'. $account->uid .'/edit')
        );
//Add in Log
//Now $account is anobject with newly user information in it
?>

Module Of Interest:-
http://drupal.org/project/user_import

Back to top

Related Pictures

Tags for Drupal User import user_save and profile fields How to import users into Drupal

Recent comments

InderSingh.com v1.2
(May 18, 2012)