Import user data using CSV
-
28-02-2021 - |
Вопрос
I want to import user information using a CSV file. I am using the BP Groups Import User plugin.
The challenge is to add the first name and last name columns in the CSV file but I cannot get the value to save.
My table is
| email | first name | last name | moderator | admin |
+------------+------------+-----------+-----------+-------+
|sm@mail.com | max | biagi | 1 | 1 |
my code
}else if(isset($_POST['create_user'])) {
//Create new user
$usermeta = array();
$usermeta['first_name'] = ucfirst ($first_name);
$usermeta['last_name'] = ucfirst ($last_name);
$usermeta['password'] = wp_hash_password( $email );
$user_login = strtok($email, '@');
$user_id = bp_core_signup_user( $user_login, $email, $email, $usermeta );
//Add user to group
groups_join_group($group_id, $user_id );
//Promote user to group moderator
if($mod){
groups_promote_member($user_id,$group_id,'mod');
}
//Promote user to group administrator
if($admin){
groups_promote_member($user_id,$group_id,'admin');
}
}
I can only save email.
Is there another way to get the value from the CSV table?
Решение
UPDATE SOLVED
I change my code to wp_insert_user beside bp_core_user_signup
$user_id = wp_insert_user(array(
'user_login' => $user_login,
'user_pass' => wp_hash_password( $email ),
'first_name' => $first_name,
'last_name' => $last_name,
'display_name' => $first_name . ' ' . $last_name,
'user_email' => $email,
'user_nicename' => $first_name
Не связан с wordpress.stackexchange