ap_user_can_restore( null|WP_Post|int $_post = null, boolean|integer $user_id = false )
Description #
Check if user can restore question or answer.
Parameters #
- $_postnull | WP_Post | int (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_restore( $_post = null, $user_id = false ) { if ( false === $user_id ) { $user_id = get_current_user_id(); } // Bail if super. if ( is_super_admin( $user_id ) ) { return true; } $_post = is_object( $_post ) ? $_post : ap_get_post( $_post ); // Return false if not question or answer. if ( ! in_array( $_post->post_type, array( 'question', 'answer' ), true ) ) { return false; } if ( user_can( $user_id, 'ap_restore_posts' ) || (int) $_post->post_author === $user_id ) { return true; } return false; }
Expand full source code Collapse full source code View on GitHub: includes/class/roles-cap.php:736
Add your comment