Ticket #8388: 8388.diff
File 8388.diff, 1.5 KB (added by , 4 years ago) |
---|
-
bp-xprofile/classes/class-bp-xprofile-profiledata.php
class BP_XProfile_ProfileData { 669 669 } 670 670 671 671 /** 672 672 * Delete all data for provided user ID. 673 673 * 674 674 * @since 1.0.0 675 675 * 676 676 * @param int $user_id User ID to remove data for. 677 677 * @return false|int 678 678 */ 679 679 public static function delete_data_for_user( $user_id ) { 680 680 global $wpdb; 681 681 682 682 $bp = buddypress(); 683 683 684 return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->profile->table_name_data} WHERE user_id = %d", $user_id ) ); 684 $field_ids = $wpdb->get_col( $wpdb->prepare( "SELECT field_id FROM {$bp->profile->table_name_data} WHERE user_id = %d", $user_id ) ); 685 686 $removed = $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->profile->table_name_data} WHERE user_id = %d", $user_id ) ); 687 688 if ( ! $removed ) { 689 return false; 690 } 691 692 foreach ( $field_ids as $field_id ) { 693 wp_cache_delete( "{$user_id}:{$field_id}", 'bp_xprofile_data' ); 694 } 695 696 return $removed; 685 697 } 686 698 687 699 /** 688 700 * Get random field type by user ID. 689 701 * 690 702 * @since 1.0.0 691 703 * 692 704 * @param int $user_id User ID to query for. 693 705 * @param string $exclude_fullname SQL portion used to exclude by field ID. 694 706 * @return array|null|object 695 707 */ 696 708 public static function get_random( $user_id, $exclude_fullname ) { 697 709 global $wpdb; 698 710 699 711 $exclude_sql = ! empty( $exclude_fullname ) ? ' AND pf.id != 1' : '';