0

I want to import user information using csv file. I use BP-Groups-Import-User plugin.

The challenge is to add column first name and last name in csv file but i can not get the value to store.

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 only can store email. Is there another way to get that value from csv table

  • Your column names appear incorrect. first name and last name probably need underscores: first_name, last_name. Are the underscores missing in your actual CSV. Does changing this help? – Jacob Peattie Sep 19 '17 at 6:00
  • thank you but is not get the data. – Diana Rider Sep 19 '17 at 6:18
1

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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