bp_get_repeater_clone_field_ids_subset( type $field_group_id, type $count )
Return ids of one field sets repeated instances.
Description
Parameters
- $field_group_id
-
(Required)
- $count
-
(Required)
Return
(array)
Source
File: bp-xprofile/bp-xprofile-repeaters.php
function bp_get_repeater_clone_field_ids_subset ( $field_group_id, $count ) {
global $wpdb;
$bp = buddypress();
$ids = array();
$template_field_ids = bp_get_repeater_template_field_ids( $field_group_id );
if ( empty( $template_field_ids ) ) {
return $ids;
}
foreach ( $template_field_ids as $template_field_id ) {
$sql = "select m1.object_id, m2.meta_value AS 'clone_number' FROM {$bp->profile->table_name_meta} as m1
JOIN {$bp->profile->table_name_meta} AS m2 ON m1.object_id = m2.object_id
WHERE m1.meta_key = '_cloned_from' AND m1.meta_value = %d
AND m2.meta_key = '_clone_number' ORDER BY m2.meta_value ASC ";
$sql = $wpdb->prepare( $sql, $template_field_id );
$results = $wpdb->get_results( $sql, ARRAY_A );
for ( $i = 1; $i <= $count; $i++ ) {
//is there a clone already?
$clone_id = false;
if ( !empty( $results ) && !is_wp_error( $results ) ) {
foreach ( $results as $row ) {
if ( $row['clone_number'] == $i ) {
$clone_id = $row['object_id'];
break;
}
}
}
//if not create one!
if ( ! $clone_id ) {
$clone_id = bp_clone_field_for_repeater_sets ( $template_field_id );
}
if ( $clone_id ) {
$ids[] = $clone_id;
}
}
}
return $ids;
}
Changelog
| Version | Description |
|---|---|
| BuddyBoss 1.0.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.