wpcom_json_api_user_can_view_post

Filter access to a specific post.

Description

apply_filters( 'wpcom_json_api_user_can_view_post', $current_user_can, (WP_Post) $post ); 

Parameters (2)

0. $current_user_can
Current_user_can( read_post,, $post->ID ) Can the current user access the post.
1. $post (WP_Post)
Post data.

Usage

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

Defined (1)

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

/class.json-api-endpoints.php  
  1. ! apply_filters(