Complete the code to check if the current user can edit posts.
<?php if (current_user_can([1])) { echo 'User can edit posts'; } ?>
The current_user_can('edit_posts') function checks if the user has permission to edit posts.
Complete the code to check if the current user can delete pages.
<?php if (current_user_can([1])) { echo 'User can delete pages'; } ?>
The current_user_can('delete_pages') function checks if the user can delete pages.
Fix the error in the code to correctly check if the user can manage options.
<?php if (current_user_can([1])) { echo 'User can manage options'; } ?>
The correct capability to check for managing options is 'manage_options'.
Fill both blanks to check if the user can edit a specific post with ID 42.
<?php if (current_user_can([1], [2])) { echo 'User can edit this post'; } ?>
Use current_user_can('edit_post', 42) to check if the user can edit the post with ID 42.
Fill all three blanks to check if the user can publish a post of type 'book'.
<?php if (current_user_can([1], [2], [3])) { echo 'User can publish book'; } ?>
The capability publish_books checks if the user can publish posts of type 'book'. The third argument 0 is often used as a placeholder for post ID when not needed.