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 |
+------------+------------+-----------+-----------+-------+
|[email protected] | 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?
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 |
+------------+------------+-----------+-----------+-------+
|[email protected] | 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?
Share Improve this question edited Apr 30, 2019 at 0:05 butlerblog 5,1313 gold badges28 silver badges44 bronze badges asked Sep 19, 2017 at 5:49 Diana RiderDiana Rider 4911 bronze badges 2 |1 Answer
Reset to default 1UPDATE 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
first name
andlast name
probably need underscores:first_name
,last_name
. Are the underscores missing in your actual CSV. Does changing this help? – Jacob Peattie Commented Sep 19, 2017 at 6:00