BP_REST_Signup_Endpoint::signup_form_items( WP_REST_Request $request )
Retrieve Signup Form Fields.
Description
Parameters
- $request
-
(Required) Full details about the request.
Return
(WP_REST_Response) | WP_Error
Source
File: bp-members/classes/class-bp-rest-signup-endpoint.php
public function signup_form_items( $request ) { $fields = array(); /* Account detail fields */ $account_fields = bp_nouveau_get_signup_fields( 'account_details' ); if ( ! empty( $account_fields ) ) { foreach ( $account_fields as $k => $field ) { if ( array_key_exists( $k, $this->default_password_fields ) ) { $field = $this->default_password_fields[ $k ]; } $fields[] = array( 'id' => $k, 'label' => $field['label'], 'description' => '', 'type' => $field['type'], 'required' => $field['required'], 'options' => '', 'member_type' => '', ); } } /* xProfile fields */ 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, ) ); if ( ! empty( $field_group ) ) { $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; }
Changelog
Version | Description |
---|---|
0.1.0 | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.