bp_dd_导入_用户_配置文件()
导入扩展配置文件字段。
描述
回来
(国际)
来源
文件:bp-core/bp-core-tools-default-data.php
函数bp_dd_import_users_profile(){$count=0;if(!bp_is_active('xprofile')){return$count;}$data=array();$xprofile_structure=require_一次(bp_DEFAULT_data_DIR.'data/xprofile_structure.php');//首先,导入配置文件组。foreach($xprofile_structure as$group_type=>$group_data){$group\u id=xprofile\u insert\u field\u group(数组('name'=>$group\u data['name'],'description'=>$group\u data['desc'],);$groups[]=$group\u id;//然后导入字段。foreach($group\u data['fields']作为$field\u type=>$field\u data){$field\u id=xprofile\u insert(数组)('field\u group\u id'=>$group\u id','parent\u id'=>0,'type'=>$field\u type,'name'=>field\u data['name'],'description'=>field\u data['desc'],'is\u required'=>field\u data['required'],'order\u by'=>'custom',);如果($field\u id){bp\u xprofile\u update\u field\u meta($field\id,'default\u可见性',$field\u数据['default-visibility');bp_xprofile_update_field_meta($field_id,'allow_custom_visibility',$field_data['allow-custom-visibility']);$data[$field_id]['type']=$field_type;//如果(!empty($field_data['options')){foreach($field_data['options']as$option){$option_id=xprofile_insert_字段(数组),最后导入选项('field_group_id'=>$group_id','parent_id'=>$field_id',type'=>'option','name'=>$option['name'],'can_delete'=>true','is_default_option'=>$option['is_default_option'],'option_order'=>$option['options]['field id]['options'['options']['options'['name'];'name'];'else.$data[$field options[$field options['id']]}}}}}}$xprofile_data=require_once(BP_DEFAULT_data_DIR.'data/xprofile_data.php');$users=BP_dd_get_random_users_id(0);//现在为每个用户的所有字段导入配置文件字段数据。foreach($users as$user_id){foreach($field id=>field_data){开关($field_data['type')){case'datebox':case'textarea':case'textbox':case'url':case'selectbox':case'radio':if(xprofile_set_field_data($field_id,$user_id,$xprofile_data['type']]]){$count break;case'checkbox':case'multiselectbox':if(xprofile_set_field data['type']]($field_id,$user_id,explode(',',$xprofile_data[$field_data['type']]].[array_rand($xprofile_data[$field_data['type']]]){$count++}break;}}如果(!empty($groups)){/**@noinspection PhpParamsInspection*/bp_update_选项('bp_dd u imported_user_xprofile_id',$groups)}返回$count
变更日志
版本 | 描述 |
---|---|
BuddyBoss 1.0.0 | 介绍。 |