BP_REST_Signup_Endpoint:: signup_form_items (WP_REST_请求$请求的)
检索注册表单字段。
描述
参数
- $请求
-
(WP_REST_请求的)(必需)有关该请求的完整详细信息。
回来
(wp_rest_response)| WP_Error
来源
文件:bp-members /类/ class-bp-rest-signup-endpoint.php
Public function signup_form_items($request) {$fields = array();/*账户详细字段*/ $account_fields = bp_nouveau_get_signup_fields('account_details');如果(!if (array_key_exists($k, $this->default_password_fields)) {$field = $this->default_password_fields[$k]; $this->default_password_fields[$k]; $this->default_password_fields;} $[] =字段数组(“id”= > $ k '标签' = >['标签'],美元的描述 ' => '', ' 美元类型' = >字段“类型”,“需要”= >字段(“需要”),美元的选项 ' => '', ' member_type ' => '', );}} /* xProfile字段*/ if (bp_is_active(' xProfile ')) {$signup_group_id = $this->bp_rest_xprofile_base_group_id();$field_group = bp_xprofile_get_groups(array('profile_group_id' => $signup_group_id, 'fetch_fields' => true,));如果(!$field_group = current($field_group); / /当前字段$fields_endpoint = new BP_REST_XProfile_Fields_Endpoint(); if ( ! empty( $field_group->fields ) ) { foreach ( $field_group->fields as $field ) { /** * Added support for display name format support from platform. */ // Get the current display settings from BuddyBoss > Settings > Profiles > Display Name Format. $current_value = bp_get_option( 'bp-display-name-format' ); // If First Name selected then do not add last name field. if ( 'first_name' === $current_value && function_exists( 'bp_xprofile_lastname_field_id' ) && bp_xprofile_lastname_field_id() === $field->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() === $field->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() === $field->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() === $field->id ) { continue; } } /** * --Added support for display name format support from platform. */ $field = $fields_endpoint->assemble_response_data( $field, $request ); $fields[] = array( 'id' => 'field_' . $field['id'], 'label' => $field['name'], 'description' => ( ! empty( $field['alternate_name'] ) ? $field['alternate_name'] : $field['name'] ), 'type' => $field['type'], 'required' => $field['is_required'], 'options' => $field['options'], 'member_type' => bp_xprofile_get_meta( $field['id'], 'field', 'member_type', false ), ); } } } } /* xProfile fields */ $blog_fields = bp_nouveau_get_signup_fields( 'blog_details' ); if ( ! empty( $blog_fields ) && bp_get_blog_signup_allowed() ) { if ( array_key_exists( 'signup_blog_privacy_public', $blog_fields ) ) { unset( $blog_fields['signup_blog_privacy_public'] ); } if ( array_key_exists( 'signup_blog_privacy_private', $blog_fields ) ) { unset( $blog_fields['signup_blog_privacy_private'] ); } $fields[] = array( 'id' => 'signup_with_blog', 'label' => __( "Yes, I'd like to create a new site", 'buddyboss' ), 'description' => '', 'type' => 'checkbox', 'required' => '', 'options' => '', ); foreach ( $blog_fields as $k => $field ) { $fields[] = array( 'id' => $k, 'label' => $field['label'], 'description' => '', 'type' => $field['type'], 'required' => $field['required'], 'options' => '', ); } $fields[] = array( 'id' => 'signup_blog_privacy', 'label' => __( 'I would like my site to appear in search engines, and in public listings around this network.', 'buddyboss' ), 'description' => '', 'type' => 'radio', 'required' => true, 'options' => array( array( 'id' => 'public', 'type' => 'option', 'name' => __( 'Yes', 'buddyboss' ), 'is_default_option' => true, ), array( 'id' => 'private', 'type' => 'option', 'name' => __( 'No', 'buddyboss' ), 'is_default_option' => false, ), ), ); } $response = rest_ensure_response( $fields ); /** * Fires after a list of signup fields is fetched via the REST API. * * @param array $fields Fetched Form fields. * @param WP_REST_Response $response The response data. * @param WP_REST_Request $request The request sent to the API. * * @since 0.1.0 */ do_action( 'bp_rest_signup_form_items', $fields, $response, $request ); return $response; }
变更乐
版本 | 描述 |
---|---|
0.1.0. | 介绍。 |