Bird
0
0

Identify the error in this code snippet for removing a user role:

medium📝 Debug Q14 of 15
Wordpress - WordPress Settings and Configuration
Identify the error in this code snippet for removing a user role:
remove_role('editor');
Aremove_role() requires two parameters
Bremove_role() cannot remove default roles
CNo error, this code correctly removes the 'editor' role
DThe role name must be capitalized
Step-by-Step Solution
Solution:
  1. Step 1: Check remove_role() usage

    The function remove_role() takes one parameter: the role slug. This usage is correct.
  2. Step 2: Verify default roles behavior

    WordPress allows removing default roles like 'editor' using remove_role(). The code executes without error, though default roles may be re-registered later.
  3. Final Answer:

    No error, this code correctly removes the 'editor' role -> Option C
  4. Quick Check:

    remove_role() works on all roles [OK]
Quick Trick: remove_role('editor') works fine [OK]
Common Mistakes:
  • Thinking remove_role needs two parameters
  • Believing default roles cannot be removed
  • Assuming role names must be capitalized

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Wordpress Quizzes