BP_REST_XProfile_Field_Groups_Endpoint::get_collection_params()

Get the query params for XProfile field groups.

Description

Return

(array)

Source

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

906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
public function get_collection_params() {
    $params                       = parent::get_collection_params();
    $params['context']['default'] = 'view';
 
    $params['profile_group_id'] = array(
        'description'       => __( 'ID of the field group that have 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 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['fetch_fields'] = array(
        'description'       => __( 'Whether to fetch the fields for each group.', '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_field_groups_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.