User Roles and Capabilities Flashcards

1
Q

Q: What is a user role in WordPress?

A

A: A collection of permissions that defines what actions a user can perform on a site.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Q: How many default user roles does WordPress have?

A

A: Six (Subscriber, Contributor, Author, Editor, Administrator, Super Admin).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Q: What is the primary purpose of user roles?

A

A: To manage access and control what users can and cannot do on a WordPress site.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Q: What is the role of a Super Admin?

A

A: A user with access to the entire network of sites in a WordPress Multisite.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Q: Where can you assign or change a user’s role in the WordPress admin?

A

A: In the Users section of the dashboard.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Q: What can a Subscriber do by default?

A

A: Manage their own profile and leave comments.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Q: What can a Contributor do by default?

A

A: Write and edit their own posts but cannot publish them.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Q: What can an Author do by default?

A

A: Publish, edit, and delete their own posts.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Q: What can an Editor do by default?

A

A: Manage and edit all posts, including those written by others.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Q: What can an Administrator do by default?

A

A: Perform all actions, including managing plugins, themes, and user roles.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Q: What are capabilities in WordPress?

A

A: Specific permissions that determine what actions a user can perform.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Q: How are capabilities linked to user roles?

A

A: Each role has a set of capabilities assigned to it.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Q: Name a capability that allows a user to edit posts.

A

A: edit_posts.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Q: Name a capability that allows a user to delete posts.

A

A: delete_posts.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Q: What capability is required to manage plugins?

A

A: activate_plugins.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Q: What function is used to add a custom role in WordPress?

A

A: add_role().

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

Q: What function is used to remove a custom role in WordPress?

A

A: remove_role().

18
Q

Q: How can you add a capability to an existing role?

A

A: Use the add_cap() method.

19
Q

Q: How can you remove a capability from an existing role?

A

A: Use the remove_cap() method.

20
Q

Q: What is the syntax for adding a custom role?

A

add_role( ‘custom_role’, ‘Custom Role Name’, array( ‘read’ => true ) );

21
Q

Q: What function checks if a user has a specific capability?

A

A: current_user_can().

22
Q

Q: How can you check if the current user is an Administrator?

A

if ( current_user_can( ‘administrator’ ) ) {
// User is an Administrator
}

23
Q

Q: How do you check if a user has the capability to edit a specific post?

A

if ( current_user_can( ‘edit_post’, $post_id ) ) {
// User can edit the post
}

24
Q

Q: What function retrieves the role of a specific user?

A

A: $user->roles.

25
Q

Q: How do you check if a user belongs to a specific role?

A

if ( in_array( ‘editor’, $user->roles ) ) {
// User is an Editor
}

26
Q

Q: Why would you create a custom user role?

A

A: To provide tailored permissions for specific site needs.

27
Q

Q: Can a custom user role inherit capabilities from another role?

A

A: No, roles are independent and must be explicitly assigned capabilities.

28
Q

Q: How can you list all roles on a WordPress site?

A

A: Use the wp_roles global variable.

29
Q

Q: What function is used to modify a user’s role programmatically?

A

A: $user->set_role( ‘role_name’ ).

30
Q

Q: How can you assign multiple roles to a user?

A

A: Use the add_role() method on the WP_User object for additional roles.

31
Q

Q: What additional role exists in WordPress Multisite?

A

A: Super Admin.

32
Q

Q: What is the difference between an Administrator and a Super Admin?

A

A: An Administrator manages a single site, while a Super Admin manages the entire network.

33
Q

Q: What capability is required to create a new site in a Multisite network?

A

A: manage_network.

34
Q

Q: How do you check if a user is a Super Admin?

A

A: is_super_admin().

35
Q

Q: What capability allows a Super Admin to manage themes?

A

A: manage_network_themes.

36
Q

Q: Why should you assign the least privileged role necessary to a user?

A

A: To enhance security by limiting access to sensitive features.

37
Q

Q: Why is it important to test custom roles before deploying them?

A

A: To ensure users can perform only the intended actions.

38
Q

Q: How can you reset roles and capabilities to their default values?

A

A: Deactivate and reactivate the theme or plugin that modified them.

39
Q

Q: Why should you use descriptive names for custom roles?

A

A: To make it clear what the role is intended for.

40
Q

Q: How can you document custom roles and capabilities for future reference?

A

A: Maintain detailed comments in your code or create separate documentation.