- Timestamp:
- 07/21/2015 02:00:38 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-xprofile/classes/class-bp-xprofile-group.php
r10009 r10022 233 233 * @type int $user_id Required if you want to load a specific user's data. 234 234 * Default: displayed user's ID. 235 * @type array|string $member_type Limit fields by those restricted to a given member type, or array of 236 * member types. If `$user_id` is provided, the value of `$member_type` 237 * will be overridden by the member types of the provided user. The 238 * special value of 'any' will return only those fields that are 239 * unrestricted by member type - i.e., those applicable to any type. 235 240 * @type bool $hide_empty_groups True to hide groups that don't have any fields. Default: false. 236 241 * @type bool $hide_empty_fields True to hide fields where the user has not provided data. Default: false. … … 252 257 'profile_group_id' => false, 253 258 'user_id' => bp_displayed_user_id(), 259 'member_type' => false, 254 260 'hide_empty_groups' => false, 255 261 'hide_empty_fields' => false, … … 319 325 $exclude_fields_cs = implode( ',', $exclude_fields_cs ); 320 326 321 // Set up IN query for field IDs327 // Set up NOT IN query for excluded field IDs. 322 328 if ( ! empty( $exclude_fields_cs ) ) { 323 329 $exclude_fields_sql = "AND id NOT IN ({$exclude_fields_cs})"; … … 326 332 } 327 333 334 // Set up IN query for included field IDs. 335 $include_field_ids = array(); 336 337 // Member-type restrictions. 338 if ( bp_get_member_types() ) { 339 if ( $r['user_id'] || false !== $r['member_type'] ) { 340 $member_types = $r['member_type']; 341 if ( $r['user_id'] ) { 342 $member_types = bp_get_member_type( $r['user_id'], false ); 343 if ( empty( $member_types ) ) { 344 $member_types = array( 'null' ); 345 } 346 } 347 348 $member_types_fields = BP_XProfile_Field::get_fields_for_member_type( $member_types ); 349 $include_field_ids += array_keys( $member_types_fields ); 350 } 351 } 352 353 $in_sql = ''; 354 if ( ! empty( $include_field_ids ) ) { 355 $include_field_ids_cs = implode( ',', array_map( 'intval', $include_field_ids ) ); 356 $in_sql = " AND id IN ({$include_field_ids_cs}) "; 357 } 358 328 359 // Fetch the fields 329 $fields = $wpdb->get_results( "SELECT id, name, description, type, group_id, is_required FROM {$bp->profile->table_name_fields} WHERE group_id IN ( {$group_ids_in} ) AND parent_id = 0 {$exclude_fields_sql} ORDER BY field_order" ); 360 $fields = $wpdb->get_results( "SELECT id, name, description, type, group_id, is_required FROM {$bp->profile->table_name_fields} WHERE group_id IN ( {$group_ids_in} ) AND parent_id = 0 {$exclude_fields_sql} {$in_sql} ORDER BY field_order" ); 361 330 362 $field_ids = wp_list_pluck( $fields, 'id' ); 331 363
Note: See TracChangeset
for help on using the changeset viewer.