The User class can be used to create, view or edit user instances. It is a Proxy class that provides a unified interface to access information on the other user sub-classes.
The sub-classes are:

  • User_Entity
  • User_Social
  • User_Registration
  • User_Info

Usage Example

$u = new User();
$u->username = "boostack";
$u->name = "Boostack System";
$u->email = "";
$u->pwd = "testing";
$u->privilege = "0";
$u->first_name = "Boostack";
$u->company = "Boostack";
$u->last_name = "System";
$u->save();// new user registration

$u = new User([id of an existing user]);
$u->name = "New Name ";
$u->save();// update user data

Use the Auth class to manage login and logout for the current user.


  • fill($array)
    The method fill the user object with array of key-value.
  • load($id)
    This method Assign the ID passed as parameter to the User id and wait for other method to execute.
  • save($forcedID)
    The method save user data into database by a Transaction. If there is a parameter ID the method invoke the save method of all under instance, otherwise save with incremental id from database and save under instance with the same id.
  • delete()
    This method is used to remove the user data from the under instance of user object.
  • jsonSerialize()
    Return an array of User object from under Instance.
  • User::existById($id, $throwException)
    Check with id parameter the existence of user on the database.
  • User::existsByEmail($email, $throwException)
    Check with email parameter the existence of user on the database.
  • User::existsByUsername($username, $throwException)
    Check with username parameter the existence of user on the database.
  • User::getUserIDByEmail($email, $throwException)
    Return the User Id from Email parameter.
  • User::getCredentialByCookie($cookieValue)
    Return username and password by cookie parameter.
  • User::getActiveCredentialByEmail($email)
    Return id and password by email parameter.
  • User::getActiveCredentialByUsername($username)
    Return id and password by username parameter.
  • User::getActiveCredentialByEmailOrUsername($email, $username)
    Return id and password by email or username parameter.
  • User::getActiveIdByEmailAndPassword($email, $password)
    Return id by email or password parameter.
  • User::getActiveIdByUsernameAndPassword($username, $password)
    Return id by username or password parameter.
  • User::getActiveIdByEmailOrUsernameAndPassword($email, $username, $password)
    Return id by email or username or password parameter.
  • refreshRememberMeCookie()
    set cookie with updated cookie value.


You can use UserList class to handle multiple user instances.

  • loadAll()
    Perform all item about user.
  • view($fields, $orderColumn, $orderType, $numitem, $currentPage)
    View method is used to render a list of user item with filter and pagination.
  • fill($array, $excludePwd)
    The fill method perform load of a single item and create the user object defined in User class.
  • getSQLFromJoinPart()
    This method used to perform a join of other table with User main table.