User profiles & rights
PHP CRUD Tutorial

Login as super-admin to the admin panel, create profiles and give them the permissions you want on each table and action.


How to add new Admin users and assign them specific permissions

  1. Login to the Admin Panel as the Main Administrator
    Use the credentials created during the installation of the authentication module

  2. Open the Users Profiles & click the Add new button

    Add New User Admin Profile
  3. Each of the tables used in the admin dashboard is shown as a set of 4 fields:

    Users profile Admin Form
    Read
    Are users with this profile allowed to Read the records of this table?
    Update
    Are users with this profile allowed to to Update the records of this table?
    Create Delete
    Are users with this profile allowed to to Create / Delete the records of this table?
  4. Give your profile a name, make your choices for each table as described in the above section, then submit to save.
  5. Open the Users & click the Add new button

    Add New Admin User
  6. Choose the new user's profile in the dropdown list, complete the user info & submit to add your new user.

    Add New Admin User
  7. Log out & log In with the new user's credentials if you want to test your new profile.

If a user does not have the right to read on a table, the table will not be displayed in the side menu.
The URL will of course not be available either.

If a user does not have the creation/edit/deletion rights on a table, the corresponding buttons will not be displayed in the data table.
The URLs will of course not be available either.

How to restrict the user's permissions to its own records?

The PHPCG authentication module allows you to create user profiles for which connected users only have access to their own records.

This allows, for example, to give access to a customer who will only see his own profile and orders.

To do this, each table to be restricted must be joined to the user table, directly or indirectly.

Admin table with a Direct Relation to the Users table
Admin table with a Direct Relation to the Users table
Admin table with a Direct Relation to the Users table
Admin table with an Indirect Relation to the Users table
  1. Open the Add new profile or Edit profile form

  2. Set the Read, Update, Create/Delete rights of the table you want to restrict to Restricted in the drodown list

  3. In the Constraint Query field, enter the WHERE query to use to limit the user's rights

    CURRENT_USER_ID will be automatically replaced by PHPCG with the current connected user ID.

    Example using the Direct Relation according to the Database shema above:
    WHERE projects.phpcg_users_ID = CURRENT_USER_ID
    Example using the Indirect Relation according to the Database shema above:
    WHERE projects_details.projects_id = projects.id AND projects.phpcg_users_ID = CURRENT_USER_ID
  4. Assign your restricted profile to any User, Log out & log In with the user's credentials if you want to test

Prerequisites

To create users profiles and add new users you must beforehand:

Back to the PHP CRUD Tutorials