BP_REST_Members_Endpoint:: xprofile_data (intuser_id美元)
从用户获取XProfile信息。
描述
参数
- user_id美元
-
(int)(必需)用户ID。
返回
(数组)
源
文件:bp-members /类/ class-bp-rest-members-endpoint.php
xprofile_data($user_id) {$data = array();//获取XProfile组,只有当组件是活动的。if (bp_is_active('xprofile')) {$fields_endpoint = new BP_REST_XProfile_Fields_Endpoint();$groups = bp_xprofile_get_groups(array('user_id' => $user_id, 'fetch_fields' => true, 'fetch_field_data' => true,));Foreach ($groups as $group) {$data['groups'][$group->id] = array('name' => $group->name,);foreach ($group->fields as $item){/** *增加了平台对显示名称格式的支持。*/ //从BuddyBoss获取当前显示设置>设置>配置>显示名称格式。$current_value = bp_get_option('bp-display-name-format');//如果选择了First Name,那么不添加last Name字段。If ('first_name' === $current_value && function_exists('bp_xprofile_lastname_field_id') && bp_xprofile_lastname_field_id() === $item->id) {If (function_exists('bp_hide_last_name') && false === bp_hide_last_name()) {continue; } // If Nick Name selected then do not add first & last name field. } elseif ( 'nickname' === $current_value && function_exists( 'bp_xprofile_lastname_field_id' ) && bp_xprofile_lastname_field_id() === $item->id ) { if ( function_exists( 'bp_hide_nickname_last_name' ) && false === bp_hide_nickname_last_name() ) { continue; } } elseif ( 'nickname' === $current_value && function_exists( 'bp_xprofile_firstname_field_id' ) && bp_xprofile_firstname_field_id() === $item->id ) { if ( function_exists( 'bp_hide_nickname_first_name' ) && false === bp_hide_nickname_first_name() ) { continue; } } if ( function_exists( 'bp_member_type_enable_disable' ) && false === bp_member_type_enable_disable() ) { if ( function_exists( 'bp_get_xprofile_member_type_field_id' ) && bp_get_xprofile_member_type_field_id() === $item->id ) { continue; } } /** * --Added support for display name format support from platform. */ $data['groups'][ $group->id ]['fields'][ $item->id ] = array( 'name' => $item->name, 'value' => array( 'raw' => $item->data->value, 'unserialized' => $fields_endpoint->get_profile_field_unserialized_value( $item->data->value ), 'rendered' => $fields_endpoint->get_profile_field_rendered_value( $item->data->value, $item ), ), ); } } } else { $data = array( __( 'No extended profile data available as the component is inactive', 'buddyboss' ) ); } return $data; }
更新日志
版本 | 描述 |
---|---|
0.1.0 | 介绍了。 |