- Timestamp:
- 04/16/2021 05:29:26 AM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-xprofile/classes/class-bp-xprofile-data-template.php
r12868 r12885 106 106 * @since 1.5.0 107 107 * @since 2.4.0 Introduced `$member_type` argument. 108 * @since 8.0.0 Introduced `$hide_field_types` argument.108 * @since 8.0.0 Introduced `$hide_field_types` & `$signup_fields_only` arguments. 109 109 * 110 110 * @param array|string $args { … … 121 121 * @type int|bool $hide_empty_fields Should empty fields be skipped. 122 122 * @type int|bool $fetch_visibility_level Fetch visibility levels. 123 * @type string[] $hide_field_types List of field types to hide form loop. Default: empty array. 124 * @type bool $signup_fields_only Whether to only return signup fields. Default: false. 123 125 * @type int|bool $update_meta_cache Should metadata cache be updated. 124 * @type string[] $hide_field_types List of field types to hide form loop. Default: empty array.125 126 * } 126 127 */ … … 160 161 'exclude_fields' => false, 161 162 'hide_field_types' => array(), 163 'signup_fields_only' => false, 162 164 'update_meta_cache' => true 163 165 ) ); 164 166 165 $this->groups = bp_xprofile_get_groups( $r ); 167 $groups = bp_xprofile_get_groups( $r ); 168 169 if ( true === $r['signup_fields_only'] && bp_get_signup_allowed() ) { 170 $signup_fields_order = bp_xprofile_get_signup_field_ids(); 171 $signup_group = new BP_XProfile_Group(); 172 $signup_group->id = 0; 173 $signup_group->name = __( 'Signup Fields', 'buddypress' ); 174 $signup_group->description = ''; 175 $signup_group->can_delete = 0; 176 $signup_group->group_order = 0; 177 $fields = array(); 178 $signup_group->fields = array(); 179 180 // Get all group fields. 181 foreach ( $groups as $group ) { 182 if ( ! $group->fields ) { 183 continue; 184 } 185 186 // Populate fields using the field ID as key. 187 foreach ( $group->fields as $signup_field ) { 188 $fields[ $signup_field->id ] = $signup_field; 189 } 190 } 191 192 if ( $fields ) { 193 // Reorder signup fields. 194 foreach ( $signup_fields_order as $ordered_signup_field_id ) { 195 if ( ! isset( $fields[ $ordered_signup_field_id ] ) ) { 196 continue; 197 } 198 199 $signup_group->fields[] = $fields[ $ordered_signup_field_id ]; 200 } 201 } 202 203 // Override groups with the signup one. 204 $groups = array( $signup_group ); 205 } 206 207 $this->groups = $groups; 166 208 $this->group_count = count( $this->groups ); 167 209 $this->user_id = $r['user_id'];
Note: See TracChangeset
for help on using the changeset viewer.