ap_user_can_read_comments( mixed $_post = null, boolean|integer $user_id = false )
Description #
Check if a user can read a comments.
Parameters #
- $_postmixed (Optional) Post ID or object. Default value: null
- $user_idboolean | integer (Optional) User ID. Default value: false
Source #
File: includes/class/roles-cap.php
function ap_user_can_read_comments( $_post = null, $user_id = false ) { $_post = ap_get_post( $_post ); if ( false === $user_id ) { $user_id = get_current_user_id(); } if ( is_super_admin( $user_id ) ) { return true; } /** * Filter to hijack ap_user_can_read_comments. * * @param boolean|string $apply_filter Apply current filter, empty string by default. * @param object $_post Post ID or object. * @param integer $user_id User ID. * @since 4.1.0 */ $filter = apply_filters( 'ap_user_can_read_comments', '', $_post, $user_id ); if ( true === $filter ) { return true; } elseif ( false === $filter ) { return false; } // If user cannot read post then return from here. if ( ! ap_user_can_read_post( $_post, $user_id ) ) { return false; } $option = ap_opt( 'read_comment_per' ); if ( 'have_cap' === $option && is_user_logged_in() && get_user_by( 'ID', $user_id )->has_cap( 'ap_read_comment' ) ) { return true; } elseif ( 'logged_in' === $option && is_user_logged_in() ) { return true; } elseif ( 'anyone' === $option ) { return true; } return false; }
Expand full source code Collapse full source code View on GitHub: includes/class/roles-cap.php:1502
Add your comment