0

I'd like to update my users list with some user from a csv file generated by another database (witch i can access too) i'd like to create dynamically a user (with username, password and so on) and other custom fields (such as language, status, and other personal variables).

I've fetched my csv (that works), but when i try to create user with wp_insert_user, nothing happens :/

here's the code:

function clients_csv($file){

$csv = array_map('str_getcsv', file($file));
for($i=0;$i<count($csv);$i++){

if(!email_exists($csv[7]) ){
print "CREATE USER";
$user_id=wp_insert_user(
array(
'user_login' => $csv[4],
'user_pass' => wp_generate_password(12,false),
'first_name' => $csv[4],
'user_email' => $csv[7],
'role' => 'sbscrbr_subscriber'
)
);
update_user_meta( $user_id, 'lingua', $csv[1] );
}
for($j=0;$j<count($csv[$i]);$j++){
print $csv[$i][$j];
}
add_user_meta($csv[0],'lingua',$csv[1]);
print "
";
}
}

just for trial purpose, i call the function in the index file.

Thanks in advance

2
  • What debugging have you tried so far? What's the return value of wp_insert_user? Jun 30, 2016 at 7:30
  • it is very unlikely that "nothing happens" please edit your question and include what does happen and what debuging steps have you tried Jun 30, 2016 at 7:30

1 Answer 1

-1

I found out the problem. i used wp_update_user to create the user, instead of wp_create_user.

my bad :/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.