BP_REST_XProfile_Repeater_Endpoint::get_repeater_fields( integer $field_id, integer $user_id, integer $group_id )
Get sub field using parent field ID and group ID.
Description
Parameters
- $field_id
-
(integer) (Required) The profile field object ID.
- $user_id
-
(integer) (Required) The ID of the user.
- $group_id
-
(integer) (Required) The profile group object ID.
Return
(array|void)
Source
File: bp-xprofile/classes/class-bp-rest-xprofile-repeater-endpoint.php
public function get_repeater_fields( $field_id, $user_id, $group_id ) { global $bp, $wpdb; if ( empty( $field_id ) || empty( $user_id ) ) { return; } // phpcs:ignore $sql = "select m1.object_id FROM {$bp->profile->table_name_meta} as m1 WHERE m1.meta_key = '_cloned_from' AND m1.meta_value = %d"; // phpcs:ignore $sql = $wpdb->prepare( $sql, $field_id ); // phpcs:ignore $results = $wpdb->get_col( $sql ); $data = array(); $user_fields = bp_get_profile_field_set_count( $group_id, $user_id ); if ( ! empty( $results ) && ! is_wp_error( $results ) ) { $count = 1; foreach ( $results as $k => $sub_field_id ) { if ( $count > $user_fields ) { break; } $data[ $sub_field_id ] = $count; $count++; } } return $data; }
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.