pods_rest_api_depth_for_relationship_response

What depth to use for a related field REST response.

Description

apply_filters( 'pods_rest_api_depth_for_relationship_response', (array) $depth, (string) $field_name, (object|Pods) $pod, (object|Pods) $related_pod, (int) $id, (object|WP_REST_Request) $request ); 

Parameters (6)

0. $depth (array)
The depth.
1. $field_name (string)
The name of the field
2. $pod (object|Pods)
The Pods" title="Pods" class="code class">Pods object for Pod relationship is from.
3. $related_pod (object|Pods)
The Pods" title="Pods" class="code class">Pods object for Pod relationship is to.
4. $id (int)
Current item ID
5. $request (object|WP_REST_Request)
Current request object.

Usage

To run the hook, copy the example below.
  1. $depth = apply_filters( 'pods_rest_api_depth_for_relationship_response', $depth, $field_name, $pod, $related_pod, $id, $request ); 
  2.  
  3. if ( !empty( $depth ) ) { 
  4.  
  5. // everything has led up to this point... 
  6.  
  7.  
The following example is for adding a hook callback.
  1. // define the pods_rest_api_depth_for_relationship_response callback 
  2. function filter_pods_rest_api_depth_for_relationship_response( $depth, $field_name, $pod, $related_pod, $id, $request ) { 
  3. // make filter magic happen here... 
  4. return $depth
  5. }; 
  6.  
  7. // add the filter 
  8. add_filter( 'pods_rest_api_depth_for_relationship_response', 'filter_pods_rest_api_depth_for_relationship_response', 10, 6 ); 
To remove a hook callback, use the example below.
  1. // remove the filter 
  2. remove_filter( 'pods_rest_api_depth_for_relationship_response', 'filter_pods_rest_api_depth_for_relationship_response', 10, 6 ); 

Defined (1)

The filter is defined in the following location(s).

/classes/PodsRESTHandlers.php  
  1. $depth = apply_filters( 'pods_rest_api_depth_for_relationship_response', $depth, $field_name, $pod, $related_pod, $id, $request );