if ( current_user_can( 'edit_post' ) ) { // Display the content for users with 'edit_post' capability } else { // Display some other content for users without 'edit_post' capability }
if ( current_user_can( 'edit_book', $post_id ) ) { echo 'Edit'; }Package library: This function is part of WordPress core.