BP_REST_Group_Membership_Request_Endpoint::prepare_links( BP_Invitation $invite )

Prepare links for the request.

Description

Parameters

$invite

(Required) Invite object.

Return

(array) Links for the given plugin.

Source

File: bp-groups/classes/class-bp-rest-group-membership-request-endpoint.php

815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
protected function prepare_links( $invite ) {
    $base = sprintf( '/%s/%s/', $this->namespace, $this->rest_base );
    $url  = $base . $invite->id;
 
    $group_id = ( ( isset( $request['group_id'] ) && ! empty( $request['group_id'] ) ) ? $request['group_id'] : 0 );
 
    // Entity meta.
    $links = array(
        'self'       => array(
            'href' => rest_url( $url ),
        ),
        'collection' => array(
            'href' => rest_url( $base ),
        ),
        'user'       => array(
            'href'       => rest_url( bp_rest_get_user_url( $invite->user_id ) ),
            'embeddable' => true,
        ),
    );
 
    if ( ! empty( $group_id ) ) {
        $links['group'] = array(
            'embeddable' => true,
            'href'       => rest_url( $this->namespace . '/' . buddypress()->groups->id . '/' . $group_id ),
        );
    }
 
    /**
     * Filter links prepared for the REST response.
     *
     * @param array $links The prepared links of the REST response.
     * @param BP_Invitation $invite Invite object.
     *
     * @since 0.1.0
     */
    return apply_filters( 'bp_rest_group_membership_requests_prepare_links', $links, $invite );
}

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.