使用内容配置文件创建新用户
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了使用内容配置文件创建新用户相关的知识,希望对你有一定的参考价值。
<?php require_once './includes/bootstrap.inc'; drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); $query = db_query("SELECT * FROM {OldUserTable}"); while ($row = db_fetch_array($query) ) { $userData = array( 'name' => $row['ID'], 'pass' => $row['PASSWORD'], 'mail' => $row['EMAIL'], 'status' => 1, 'roles' => $role ); try { $new_user = user_save('', $userData); $good_count++; try { $profile_node = new stdClass(); $profile_node->title = $new_user->name; $profile_node->body = ''; $profile_node->type = 'profile'; // Your specified content type $profile_node->created = $time; $profile_node->changed = $time; $profile_node->status = 1; $profile_node->promote = 0; $profile_node->sticky = 0; $profile_node->uid = $new_user->uid; // UID of content owner $profile_node->field_first_name[0]['value'] = $row['FIRST']; $profile_node->field_last_name[0]['value'] = $row['LAST']; $profile_node->field_location[0]['street'] = $row['ADDRESS']; $profile_node->field_location[0]['city'] = $row['CITY']; $profile_node->field_location[0]['province'] = $row['STATE']; $profile_node->field_location[0]['postal_code'] = $row['ZIP']; $profile_node->field_location[0]['country_name'] = 'United States'; $profile_node->field_location[0]['phone'] = $row['PHONE']; $profile_node->field_location[0]['fax'] = $row['FAX']; node_save($profile_node); } catch (Exception $e) { echo 'Caught exception: ', $e->getMessage(), " "; } } catch (Exception $e) { echo 'Caught exception: ', $e->getMessage(), " "; } } ?>
以上是关于使用内容配置文件创建新用户的主要内容,如果未能解决你的问题,请参考以下文章
使用 Angular 和 Firebase 登录后获取用户配置文件