BP_REST_Group_Membership_Endpoint::get_endpoint_args_for_method( string $method = WP_REST_Server::CREATABLE )
GET arguments for the endpoint’s CREATABLE, EDITABLE & DELETABLE methods.
Description
Parameters
- $method
-
(Optional) HTTP method of the request.
Default value: WP_REST_Server::CREATABLE
Return
(array) Endpoint arguments.
Source
File: bp-groups/classes/class-bp-rest-group-membership-endpoint.php
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 | public function get_endpoint_args_for_method( $method = WP_REST_Server::CREATABLE ) { $key = 'get_item' ; $args = array ( 'context' => $this ->get_context_param( array ( 'default' => 'edit' , ) ), ); if ( WP_REST_Server::CREATABLE === $method || WP_REST_Server::EDITABLE === $method ) { $group_roles = array_diff ( array_keys ( bp_groups_get_group_roles() ), array ( 'banned' ) ); $args [ 'role' ] = array ( 'description' => __( 'Group role to assign the user to.' , 'buddyboss' ), 'default' => 'member' , 'type' => 'string' , 'enum' => $group_roles , 'sanitize_callback' => 'sanitize_key' , 'validate_callback' => 'rest_validate_request_arg' , ); if ( WP_REST_Server::CREATABLE === $method ) { $key = 'create_item' ; $schema = $this ->get_item_schema(); $args [ 'user_id' ] = array_merge ( $schema [ 'properties' ][ 'id' ], array ( 'description' => __( 'A unique numeric ID for the Member to add to the Group.' , 'buddyboss' ), 'default' => bp_loggedin_user_id(), 'required' => true, 'readonly' => false, ) ); } if ( WP_REST_Server::EDITABLE === $method ) { $key = 'update_item' ; $args [ 'action' ] = array ( 'description' => __( 'Action used to update a group member.' , 'buddyboss' ), 'default' => 'promote' , 'type' => 'string' , 'enum' => array ( 'promote' , 'demote' , 'ban' , 'unban' ), 'sanitize_callback' => 'sanitize_key' , 'validate_callback' => 'rest_validate_request_arg' , ); } } elseif ( WP_REST_Server::DELETABLE === $method ) { $key = 'delete_item' ; } /** * Filters the method query arguments. * * @param array $args Query arguments. * @param string $method HTTP method of the request. * * @since 0.1.0 */ return apply_filters( "bp_rest_group_members_{$key}_query_arguments" , $args , $method ); } |
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.