Bird
0
0

How can you programmatically check if a user with ID 5 has the capability to 'edit_pages'?

hard📝 Application Q9 of 15
Wordpress - WordPress Settings and Configuration
How can you programmatically check if a user with ID 5 has the capability to 'edit_pages'?
Acurrent_user_can('edit_pages')
Buser_can(5, 'edit_pages')
Ccheck_user_capability(5, 'edit_pages')
Dhas_capability(5, 'edit_pages')
Step-by-Step Solution
Solution:
  1. Step 1: Identify function to check capability for specific user

    user_can(user_id, capability) checks capability for given user ID.
  2. Step 2: Confirm correct syntax

    Passing 5 and 'edit_pages' matches user_can() usage.
  3. Final Answer:

    user_can(5, 'edit_pages') -> Option B
  4. Quick Check:

    Use user_can() for specific user ID checks [OK]
Quick Trick: Use user_can(userID, capability) to check any user [OK]
Common Mistakes:
  • Using current_user_can() for other users
  • Using non-existent functions
  • Wrong parameter order

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Wordpress Quizzes