ap_user_can_ask( integer|boolean $user_id = false )
Description #
Check if a user can ask a question.
Parameters #
- $user_idinteger | boolean (Optional) User_id. Default value: false
Changelog #
Source #
File: includes/class/roles-cap.php
function ap_user_can_ask( $user_id = false ) { if ( false === $user_id ) { $user_id = get_current_user_id(); } if ( is_super_admin( $user_id ) ) { return true; } /** * Filter to hijack ap_user_can_ask function. * * @param boolean|string $filter Apply this filter, empty string by default. * @param integer $user_id User ID. * @return boolean * @since 2.4.6 */ $filter = apply_filters( 'ap_user_can_ask', '', $user_id ); if ( true === $filter ) { return true; } elseif ( false === $filter ) { return false; } $option = ap_opt( 'post_question_per' ); if ( 'have_cap' === $option && is_user_logged_in() && user_can( $user_id, 'ap_new_question' ) ) { 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:125
Add your comment