Bird
0
0

You want to create a custom role 'content_manager' that can edit posts and moderate comments. Which code snippet correctly adds this role with these capabilities?

hard📝 Application Q15 of 15
Wordpress - WordPress Settings and Configuration
You want to create a custom role 'content_manager' that can edit posts and moderate comments. Which code snippet correctly adds this role with these capabilities?
Aadd_role('content_manager', 'Content Manager', ['edit_posts' => true, 'moderate_comments' => true]);
Badd_role('content_manager', 'Content Manager', ['edit_posts', 'moderate_comments']);
Cadd_role('content_manager', 'Content Manager', ['edit_posts' => false, 'moderate_comments' => true]);
Dadd_role('content_manager', 'Content Manager', ['edit_posts' => true, 'delete_posts' => true]);
Step-by-Step Solution
Solution:
  1. Step 1: Understand add_role() parameters

    The function takes role slug, display name, and an array of capabilities with boolean values.
  2. Step 2: Check capabilities array

    Capabilities must be keys with true/false values to grant or deny permissions.
  3. Step 3: Match required capabilities

    Only add_role('content_manager', 'Content Manager', ['edit_posts' => true, 'moderate_comments' => true]); correctly grants 'edit_posts' and 'moderate_comments' as true.
  4. Final Answer:

    add_role('content_manager', 'Content Manager', ['edit_posts' => true, 'moderate_comments' => true]); -> Option A
  5. Quick Check:

    Capabilities array with true values = correct role setup [OK]
Quick Trick: Capabilities array needs keys with true/false values [OK]
Common Mistakes:
  • Passing capabilities as list without keys
  • Setting capability to false when it should be true
  • Adding wrong capabilities not requested

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Wordpress Quizzes