ap_user_can_view_moderate_post( integer $post_id = null, integer $user_id = false )
Description #
Check if user can view a moderate post.
Parameters #
- $post_idinteger (Optional) Question ID. Default value: null
- $user_idinteger (Optional) User ID. Default value: false
Source #
File: includes/class/roles-cap.php
function ap_user_can_view_moderate_post( $post_id = null, $user_id = false ) { if ( false === $user_id ) { $user_id = get_current_user_id(); } if ( is_super_admin( $user_id ) || user_can( $user_id, 'ap_view_moderate' ) ) { return true; } $post_o = ap_get_post( $post_id ); // Bail if not answer or question. if ( ! $post_o || ! ap_is_cpt( $post_o ) ) { return false; } // Return false if the post status is not set to moderate. if ( 'moderate' !== $post_o->post_status ) { return false; } if ( is_user_logged_in() && $post_o->post_author == $user_id ) { // phpcs:ignore Universal.Operators.StrictComparisons.LooseEqual return true; } if ( ! is_user_logged_in() && '0' === $post_o->post_author && anspress()->session->post_in_session( $post_o ) ) { return true; } return false; }
Expand full source code Collapse full source code View on GitHub: includes/class/roles-cap.php:813
Add your comment