BP_REST_XProfile_Fields_Endpoint::get_collection_params()

Get the query params for the XProfile fields.

Description

Return

(array)

Source

File: bp-xprofile/classes/class-bp-rest-xprofile-fields-endpoint.php

1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
public function get_collection_params() {
    $params                       = parent::get_collection_params();
    $params['context']['default'] = 'view';
 
    $params['profile_group_id'] = array(
        'description'       => __( 'ID of the profile group of fields that have profile fields', 'buddyboss' ),
        'default'           => 0,
        'type'              => 'integer',
        'sanitize_callback' => 'absint',
        'validate_callback' => 'rest_validate_request_arg',
    );
 
    $params['hide_empty_groups'] = array(
        'description'       => __( 'Whether to hide profile groups of fields that do not have any profile fields or not.', 'buddyboss' ),
        'default'           => false,
        'type'              => 'boolean',
        'sanitize_callback' => 'rest_sanitize_boolean',
        'validate_callback' => 'rest_validate_request_arg',
    );
 
    $params['user_id'] = array(
        'description'       => __( 'Required if you want to load a specific user\'s data.', 'buddyboss' ),
        'default'           => bp_loggedin_user_id(),
        'type'              => 'integer',
        'sanitize_callback' => 'absint',
        'validate_callback' => 'rest_validate_request_arg',
    );
 
    $params['member_type'] = array(
        'description'       => __( 'Limit fields by those restricted to a given member type, or array of member types. If `$user_id` is provided, the value of `$member_type` will be overridden by the member types of the provided user. The special value of \'any\' will return only those fields that are unrestricted by member type - i.e., those applicable to any type.', 'buddyboss' ),
        'default'           => array(),
        'type'              => 'array',
        'items'             => array( 'type' => 'string' ),
        'sanitize_callback' => 'bp_rest_sanitize_member_types',
        'validate_callback' => 'bp_rest_validate_member_types',
    );
 
    $params['hide_empty_fields'] = array(
        'description'       => __( 'Whether to hide profile fields where the user has not provided data or not.', 'buddyboss' ),
        'default'           => false,
        'type'              => 'boolean',
        'sanitize_callback' => 'rest_sanitize_boolean',
        'validate_callback' => 'rest_validate_request_arg',
    );
 
    $params['fetch_field_data'] = array(
        'description'       => __( 'Whether to fetch data for each field. Requires a $user_id.', 'buddyboss' ),
        'default'           => false,
        'type'              => 'boolean',
        'sanitize_callback' => 'rest_sanitize_boolean',
        'validate_callback' => 'rest_validate_request_arg',
    );
 
    $params['fetch_visibility_level'] = array(
        'description'       => __( 'Whether to fetch the visibility level for each field.', 'buddyboss' ),
        'default'           => false,
        'type'              => 'boolean',
        'sanitize_callback' => 'rest_sanitize_boolean',
        'validate_callback' => 'rest_validate_request_arg',
    );
 
    $params['exclude_groups'] = array(
        'description'       => __( 'Ensure result set excludes specific profile field groups.', 'buddyboss' ),
        'default'           => array(),
        'type'              => 'array',
        'items'             => array( 'type' => 'integer' ),
        'sanitize_callback' => 'bp_rest_sanitize_string_list',
        'validate_callback' => 'rest_validate_request_arg',
    );
 
    $params['exclude_fields'] = array(
        'description'       => __( 'Ensure result set excludes specific profile fields.', 'buddyboss' ),
        'default'           => array(),
        'type'              => 'array',
        'items'             => array( 'type' => 'string' ),
        'sanitize_callback' => 'bp_rest_sanitize_string_list',
        'validate_callback' => 'rest_validate_request_arg',
    );
 
    $params['update_meta_cache'] = array(
        'description'       => __( 'Whether to pre-fetch xprofilemeta for all retrieved groups, fields, and data.', 'buddyboss' ),
        'default'           => true,
        'type'              => 'boolean',
        'sanitize_callback' => 'rest_sanitize_boolean',
        'validate_callback' => 'rest_validate_request_arg',
    );
 
    /**
     * Filters the collection query params.
     *
     * @param array $params Query params.
     */
    return apply_filters( 'bp_rest_xprofile_fields_collection_params', $params );
}

Changelog

Changelog
Version Description
0.1.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.