我想使用CSV文件导入用户信息。我正在使用BP Groups Import User plugin.
挑战是在CSV文件中添加名字和姓氏列,但我无法获得要保存的值。
我的桌子是
| email | first name | last name | moderator | admin |
+------------+------------+-----------+-----------+-------+
|[email protected] | max | biagi | 1 | 1 |
我的代码
}else if(isset($\\u POST[\'create\\u 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\');
}
}
我只能保存电子邮件。
是否有其他方法可以从CSV表中获取值?
最合适的回答,由SO网友:Diana Rider 整理而成
已解决更新
我将代码更改为bp\\u core\\u user\\u signup旁边的wp\\u insert\\u user
$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