How to register custom permissions and permission groups into the LA24Core role management system.
Overview
LA24Core exposes two filters to integrate custom permissions into its role management interface:
- `la24_groups_permission` — registers a named group (section header in the Manage Groups UI)
- `la24_capability` — registers individual permissions that belong to a group
Registered capabilities appear in the **Manage Groups** page where administrators assign them to roles.

Permission Groups: la24_groups_permission
**Type:** Filter
**Parameters:** `$group` (array)
**Returns:** array
php
add_filter( 'la24_groups_permission', function ( $group ) {
$group['my-crm-group'] = __( 'My CRM Module', 'my-crm-ext' );
return $group;
} );
- The array key (`'my-crm-group'`) is the group ID referenced by capabilities via `gp_id`
- The value is the display name shown as a section header in Manage Groups
- Always register a group **before** using its ID in `la24_capability`
Capabilities: la24_capability
**Type:** Filter
**Parameters:** `$capability` (array)
**Returns:** array
php
add_filter( 'la24_capability', function ( $capability ) {
$capability['my_crm_view_reports'] = array(
'name' => __( 'Permission to view CRM reports', 'my-crm-ext' ),
'gp_id' => 'my-crm-group', // must match a registered group key
);
$capability['my_crm_export_data'] = array(
'name' => __( 'Permission to export CRM data', 'my-crm-ext' ),
'gp_id' => 'my-crm-group',
);
return $capability;
} );
**Capability fields:**
| Field | Type | Description |
|---|---|---|
| Key (array key) | string | Unique capability slug, used in `la24_user_can()` calls |
| `name` | string | Human-readable description shown in Manage Groups UI |
| `gp_id` | string | Group ID from `la24_groups_permission` |
Checking Capabilities in Code
Use the `la24_user_can()` helper anywhere in your plugin:
php
if ( la24_user_can( get_current_user_id(), 'my_crm_view_reports' ) ) {
// user has access — render content
}
php
// Deny access and show template if permission is missing
if ( ! la24_user_can( get_current_user_id(), 'my_crm_export_data' ) ) {
la24_get_template( 'AccessDenied.php' );
return;
}
Registration Order
Capabilities reference group IDs, so register groups before capabilities. Since both filters run at the same priority by default, attach the group filter at a lower priority number (runs first):
php
// Groups registered at priority 5 (earlier)
add_filter( 'la24_groups_permission', 'my_register_groups', 5 );
// Capabilities registered at priority 10 (default, later)
add_filter( 'la24_capability', 'my_register_caps', 10 );
How Groups and Capabilities Appear in the UI
- Go to **Settings → Manage Groups** in the CRM panel
- Your group appears as a section header
- Your capabilities appear as checkboxes under that section
- Administrators toggle capabilities per role
