xprofile_delete_clones_on_template_delete( BP_XProfile_Field $field )
Delete repeater/clone fields when the main/template field is deleted.
Description
Parameters
- $field
-
(Required) Description
Source
File: bp-xprofile/bp-xprofile-repeaters.php
function xprofile_delete_clones_on_template_delete ( $field ) { global $wpdb; $bp = buddypress(); //get all clone field ids $clone_ids = $wpdb->get_col( $wpdb->prepare( "SELECT f.id FROM {$bp->profile->table_name_fields} AS f JOIN {$bp->profile->table_name_meta} AS fm ON f.id = fm.object_id " . " WHERE f.parent_id = 0 AND fm.meta_key = '_cloned_from' AND fm.meta_value = %d ", $field->id ) ); if ( empty( $clone_ids ) || is_wp_error( $clone_ids ) ) { return; } foreach ( $clone_ids as $clone_id ) { $clone_field = xprofile_get_field( $clone_id ); $clone_field->delete( true ); } }
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.