O'Reilly logo

Building Web Apps with WordPress by Jason Coleman, Brian Messenlehner

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 6. Users, Roles, and Capabilities

Back in Chapter 1, we established logins as a crucial component of any web app. One of the great things about using WordPress for your apps is that you get fully featured user management out of the box.

The base WordPress app includes:

  • Secure logins with passwords that are salted and hashed
  • User records with an email address, username, display name, avatar, and bio
  • Admin views to browse, search, add, edit, and delete users
  • User roles to separate administrators from editors, authors, contributors, and subscribers
  • Pages for users to login, register, and reset passwords

By using various WordPress functions and APIs, we can:

  • Add and manage user meta or profile fields for each user.
  • Define custom roles and capabilities for finer control over which users have access to what.

Managing users in WordPress is a fairly straightforward affair. The User tab in the dashboard makes it easy to browse, search, add, edit, and delete users. It’s easy to manage users via code as well.

This chapter will cover:

  • How to access user data in your code
  • How to add custom fields to users
  • How to customize the user profiles and reports in the dashboard
  • How to add, update, and delete users
  • How to define custom roles and capabilities
  • How to extend the WordPress User class to create your own user-focused classes

Getting User Data

In this section, we’ll go over how to instantiate a WordPress user object in code and how to get basic user information, like login and ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required