BP_REST_Messages_Endpoint::get_collection_params()

Get the query params for Messages collections.

Description

Return

(array)

Source

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

1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
public function get_collection_params() {
    $params                       = parent::get_collection_params();
    $params['context']['default'] = 'view';
    $boxes                        = array( 'sentbox', 'inbox' );
 
    if ( bp_is_active( 'messages', 'star' ) ) {
        $boxes[] = 'starred';
    }
 
    $params['box'] = array(
        'description'       => __( 'Filter the result by box.', 'buddyboss' ),
        'default'           => 'inbox',
        'type'              => 'string',
        'enum'              => $boxes,
        'sanitize_callback' => 'sanitize_key',
        'validate_callback' => 'rest_validate_request_arg',
    );
 
    $params['type'] = array(
        'description'       => __( 'Filter the result by thread status.', 'buddyboss' ),
        'default'           => 'all',
        'type'              => 'string',
        'enum'              => array( 'all', 'read', 'unread' ),
        'sanitize_callback' => 'sanitize_key',
        'validate_callback' => 'rest_validate_request_arg',
    );
 
    $params['user_id'] = array(
        'description'       => __( 'Limit result to messages created by a specific user.', 'buddyboss' ),
        'default'           => bp_loggedin_user_id(),
        'type'              => 'integer',
        'required'          => true,
        'sanitize_callback' => 'absint',
        'validate_callback' => 'rest_validate_request_arg',
    );
 
    /**
     * Filters the collection query params.
     *
     * @param array $params Query params.
     */
    return apply_filters( 'bp_rest_messages_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.