ap_user_can_permanent_delete( null|WP_Post|int $post = null, false|int $user_id = false )

Description #

Check if user can permanently delete a AnsPress posts

Parameters #

  • $post
    null | WP_Post | int (Optional) Post id or object. Default value: null
  • $user_id
    false | int (Optional) User id. Default value: false

Source #

File: includes/class/roles-cap.php

function ap_user_can_permanent_delete( $post = null, $user_id = false ) {
	if ( false === $user_id ) {
		$user_id = get_current_user_id();
	}

	$_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 ( is_super_admin( $user_id ) || user_can( $user_id, 'ap_delete_post_permanent' ) ) {
		return true;
	}

	return false;
}

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Add your comment