BP_REST_Group_Membership_Endpoint::prepare_links( WP_User $user, WP_REST_Request $request )
Prepare links for the request.
Description
Parameters
- $user
-
(Required) User object.
- $request
-
(Required) Full details about the request.
Return
(array)
Source
File: bp-groups/classes/class-bp-rest-group-membership-endpoint.php
876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 | protected function prepare_links( $user , $request ) { $base = sprintf( '/%s/%s/' , $this -> namespace , $this ->rest_base ); $url = $base . $user ->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 ), ), ); 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 WP_User $user User object. * * @since 0.1.0 */ return apply_filters( 'bp_rest_group_members_prepare_links' , $links , $user ); } |
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.