GreenCheap, comes with a ready-made registration procedure and a powerful user manager. With all these users on your system, your extension can easily use roles and permissions.
Users a representation of a person registered to your site and identified by their username. Status of a user account enabled, it can be blocked or new . Users can log in to your site or admin area. Not all users are allowed access to the administrator area of their accounts.
Permissions defines actions that a user can perform. Permission is defined by a name, for example
user: access admin area. Permission names must be descriptive and begin with the name of the corresponding module, etc.
user: for user module.
Roles groups several user accounts. All users with the same role share the same permissions. Roles are also used to manage access to elements of your site's content. A user can belong to zero, one, or more roles. A role can have many users assigned to it. GreenCheap comes with default roles anonymous, authenticated and administrator and lets you create as much as you need.
Roles are very flexible about how they can be used. You can create specific content that can only be accessed by selected users.
This item is now visible only to users who have signed in to the Premium role.
Note Your administrator account will also not be able to see this content unless you add the user to the Premium role or enable the Administrator option in the Restrict access settings.
To add a permission to the system field that can then be assigned a role, use the keyword
permissions in the in
php.file for an extension.
Use speech permission names. The rule is to start with the name of the extension and then have a short statement describing the permission.
Title is the string displayed in the browser.
_() Its call makes this string translatable.
'permissions' => [ 'hello: manage settings' => [ 'title' => _('Manage settings') ], ],
Check whether the user has a specific identity role.
$role_id = 4; App::user()->hasRole($role_id);
Check if the user has a role with the specified name.
$role_name = "Editor"; $role = Role::where('name = ?', [$role_name])->first(); App::user()->hasRole($role->id);
We'll let you know about new announcements, publications and everything else on our social media accounts.
Contact us directly at firstname.lastname@example.org