Book Image

WordPress Web Application Development

By : Rakhitha Nimesh Ratnayake
Book Image

WordPress Web Application Development

By: Rakhitha Nimesh Ratnayake

Overview of this book

Table of Contents (19 chapters)
WordPress Web Application Development Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Getting started with user roles


In simple terms, user roles define the types of users in a system. WordPress offers built-in functions for working with every aspect of user roles. In this section, we will look at how we can manage these tasks by implementing the user roles for our application. We can create a new user role by calling the add_role function. The following code illustrates the basic form of user role creation:

$result = add_role( 'role_name', 'Display Name', array( 'read' => true, 'edit_posts' => true, 'delete_posts' => false ) );

The first parameter takes the role name, which is a unique key to identify the role. The second parameter will be the display name, which will be shown in the admin area. The final parameter will take the necessary capabilities of the user role. You can find out more about existing user roles at http://codex.wordpress.org/Roles_and_Capabilities. In this scenario, read, edit_posts, and delete_posts will be the capabilities while true and false...