ap_user_can_view_post( integer|false $post_id = false, integer|false $user_id = false )
Description #
Check if user can view post
Parameters #
- $post_idinteger | false (Optional) Question or answer ID. Default value: false
- $user_idinteger | false (Optional) User ID. Default value: false
Source #
File: includes/class/roles-cap.php
function ap_user_can_view_post( $post_id = false, $user_id = false ) { if ( false === $user_id ) { $user_id = get_current_user_id(); } if ( is_super_admin( $user_id ) ) { return true; } $post_o = is_object( $post_id ) ? $post_id : ap_get_post( $post_id ); // Return false if not question or answer. if ( ! in_array( $post_o->post_type, array( 'question', 'answer' ), true ) ) { return false; } if ( 'private_post' === $post_o->post_status && ap_user_can_view_private_post( $post_o->ID, $user_id ) ) { return true; } if ( 'moderate' === $post_o->post_status && ap_user_can_view_moderate_post( $post_o->ID, $user_id ) ) { return true; } if ( 'future' === $post_o->post_status && ap_user_can_view_future_post( $post_o->ID, $user_id ) ) { return true; } if ( 'publish' === $post_o->post_status ) { return true; } return false; }
Expand full source code Collapse full source code View on GitHub: includes/class/roles-cap.php:897
Add your comment