user management basics cms php

14
User Management Basics www.prodigyview.com

Upload: prodigyview

Post on 05-Dec-2014

3.005 views

Category:

Technology


3 download

DESCRIPTION

Learn how to use part of ProdigyView CMS, the user management. Create, update, login and delete users.

TRANSCRIPT

Page 1: User Management Basics CMS PHP

User Management Basics

www.prodigyview.com

Page 2: User Management Basics CMS PHP

Overview

Objective

Learn to create, update, delete, and login users in ProdigyView.

Requirements

Install version of ProdigyView with a database connection

Estimated Time

10 Minutes

www.prodigyview.com

Page 3: User Management Basics CMS PHP

Follow Along With Code Example

1. Download a copy of the example code at www.prodigyview.com/source.

2.Install the system in an environment you feel comfortable testing in.

3.Proceed to examples/user/Users.php

Page 4: User Management Basics CMS PHP

Users….what about themA user…a better term would be end users… are probably the life source of what ever you are building. Without saying, you need a way to manage them. For this tutorial we are going to cover:

Creating Users

Logging In

Updating Users

Searching for Users

Deleting Users

Aspects such as user roles, content multi authors, roles, access levels, etc will come later.

Page 5: User Management Basics CMS PHP

Creating A UserCreating a user is fairly simply. Fields are added to an array and passed to PVUsers::addUser() method. Technically the only field required is the user’s email but lets define some other fields.

1. Create the fields 2.Passwords will be MD5 encoded

3. Pass arguments to addUser 4. If set to false, the password is not considered hashed and will be hashed

Page 6: User Management Basics CMS PHP

Attempt LoginNow that we have a user and we want them to login with their email or username. Let’s give it a try.

1. Pass the user’s email 2. Pass the user’s password in 3.Set the cookies on login

4. Check if the user is logged in

www.prodigyview.com

Page 7: User Management Basics CMS PHP

Force LoginSometimes we need to forcefully log the user in without password verification. This can be done through PVUsers::loginUser(). Either pass in the user’s name or the user’s email.

www.prodigyview.com

Page 8: User Management Basics CMS PHP

Retrieving the User Info

We have a user in the database and will at some point need to retrieve their information. If the user’s email or id is known, their information can be retrieved through those values.

1. Retrieve a user’s information using their id

2. Retrieve a user’s information using their email

Page 9: User Management Basics CMS PHP

Searching For usersLet’s say we have multiple user’s with our growing site and we need to somehow search for them based on certain criteria. Take a look at the ProdigyView’s Standard Search Arguments and combined with PVUsers::getUserList we can get our results.

Page 10: User Management Basics CMS PHP

Updating A UserUser’s can be finicky. They want to update their info, change their image, etc. Fine, lets give them what they want. Updating fields can be accomplished by passing the users fields in an array to PVUsers::updateUser(). The only required field is the user’s id.

1. Retrieve the user’s information, returns an array

2. Update a field in the array 3.Update the user using the array

Page 11: User Management Basics CMS PHP

And DeletingAfter all the trouble creating a users account, updating their information, the free coffee, they decide they want to delete their account. Let’s comply.

Delete a user using their id

Page 12: User Management Basics CMS PHP

Challenge!We know how to create, update and login a user. For this challenge we do not want MD5 hashing of the password but want to encrypt the password ourselves.

Use PVSecurity to create a hashed password and attempt to login with that password.

Page 13: User Management Basics CMS PHP

The Not So Obvious1. When a user is deleted, content they are considered

owner of is also deleted. This include subscriptions, points, content, options and relationships, categories and multi-author.

2. When updating a user, it is best to retrieve and pass in the whole user document for that user. The reason is because fields that are left empty will be reverted to their default value.

3. When a user is logged in, the data in that user’s row from the database is stored in session/cookie. The column’s name acts the key and columns value is the value stored.

Ex: $user_email=PVSession::readSeassion(‘user_email’);

Page 14: User Management Basics CMS PHP

API ReferenceFor a better understanding of the users, visit the api by clicking on the link below.

PVUsers

www.prodigyview.com

More Tutorials

For more tutorials, please visit:

http://www.prodigyview.com/tutorials