BP_REST_Members_Endpoint::get_collection_params()

Get the query params for collections.

Description

Return

(array)

Source

File: bp-members/classes/class-bp-rest-members-endpoint.php

1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
public function get_collection_params() {
    $params = array_intersect_key(
        parent::get_collection_params(),
        array(
            'context'  => true,
            'page'     => true,
            'per_page' => true,
            'search'   => true,
        )
    );
 
    $params['type'] = array(
        'description'       => __( 'Shorthand for certain orderby/order combinations.', 'buddyboss' ),
        'default'           => 'newest',
        'type'              => 'string',
        'enum'              => array( 'active', 'newest', 'alphabetical', 'random', 'online', 'popular' ),
        'sanitize_callback' => 'sanitize_key',
        'validate_callback' => 'rest_validate_request_arg',
    );
 
    $params['user_id'] = array(
        'description'       => __( 'Limit results to friends of a user.', 'buddyboss' ),
        'default'           => 0,
        'type'              => 'integer',
        'sanitize_callback' => 'absint',
        'validate_callback' => 'rest_validate_request_arg',
    );
 
    $params['user_ids'] = array(
        'description'       => __( 'Pass IDs of users to limit result set.', 'buddyboss' ),
        'default'           => array(),
        'type'              => 'array',
        'items'             => array( 'type' => 'integer' ),
        'sanitize_callback' => 'wp_parse_id_list',
        'validate_callback' => 'rest_validate_request_arg',
    );
 
    $params['include'] = array(
        'description'       => __( 'Ensure result set includes specific IDs.', 'buddyboss' ),
        'default'           => array(),
        'type'              => 'array',
        'items'             => array( 'type' => 'integer' ),
        'sanitize_callback' => 'wp_parse_id_list',
        'validate_callback' => 'rest_validate_request_arg',
    );
 
    $params['exclude'] = array(
        'description'       => __( 'Ensure result set excludes specific IDs.', 'buddyboss' ),
        'default'           => array(),
        'type'              => 'array',
        'items'             => array( 'type' => 'integer' ),
        'sanitize_callback' => 'wp_parse_id_list',
        'validate_callback' => 'rest_validate_request_arg',
    );
 
    $params['member_type'] = array(
        'description'       => __( 'Limit results set to certain type(s).', 'buddyboss' ),
        'default'           => array(),
        'type'              => 'array',
        'items'             => array( 'type' => 'string' ),
        'sanitize_callback' => 'bp_rest_sanitize_string_list',
        'validate_callback' => 'rest_validate_request_arg',
    );
 
    $params['xprofile'] = array(
        'description'       => __( 'Limit results set to a certain xProfile field.', 'buddyboss' ),
        'default'           => '',
        'type'              => 'string',
        'sanitize_callback' => 'sanitize_key',
        'validate_callback' => 'rest_validate_request_arg',
    );
 
    $params['bp_ps_search'] = array(
        'description' => __( 'Profile Search form field data(s).', 'buddyboss' ),
        'default'     => array(),
        'type'        => 'object',
    );
 
    $params['scope'] = array(
        'description'       => __( 'Limit result set to items with a specific scope.', 'buddyboss' ),
        'type'              => 'string',
        'default'           => 'all',
        'enum'              => array( 'all', 'personal', 'following', 'followers' ),
        'sanitize_callback' => 'sanitize_text_field',
        'validate_callback' => 'rest_validate_request_arg',
    );
 
    /**
     * Filters the collection query params.
     *
     * @param array $params Query params.
     */
    return apply_filters( 'bp_rest_members_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.