Understanding Capabilities (RBAC Explained)
JiffyTrade uses a structured capability system to control permissions.
Each action inside the plugin is protected by a specific capability.
RBAC allows you to define the minimum WordPress role required for each capability.
🧠 What Is a Capability?
A capability represents a specific action a user can perform.
Examples:
- View documents
- Send invoices
- Mark invoices as paid
- Permanently delete documents
- Manage customers
- Access backups
- View reports
You configure which role is required for each capability.
🔗 Capability Hierarchy (How Permissions Cascade)
Certain capabilities logically depend on others.
JiffyTrade enforces consistency rules so permission structures make sense.
Below is the agreed capability relationship structure.
👥 Customer Capabilities
manage_customers≥view_customersdelete_customers≥manage_customers
Meaning:
- A user who can manage customers must also be able to view them.
- A user who can delete customers must be able to manage them.
Additionally:
Customers cannot be deleted while linked documents exist.
The system blocks deletion until all related documents are removed.
📄 Document Capabilities
manage_documents≥view_documentscancel_documents≥manage_documentsissue_quotes_invoices≥manage_documentsmark_invoices_paid≥issue_quotes_invoicesunlock_documents≥manage_documentsunlock_financial_documents≥unlock_documentssend_reminders≥view_documents
This ensures:
- You cannot issue documents without being able to manage them.
- You cannot mark invoices as paid unless you can issue them.
- You cannot unlock financial documents unless you can unlock documents generally.
- Reminder sending requires visibility of documents.
🗑 Trash & Deletion Capabilities
restore_trashed_documents≥trash_documentsdelete_documents_permanently≥trash_documentsdelete_documents_permanently≥restore_trashed_documents
This ensures:
- Anyone restoring documents can also move them to Trash.
- Permanent deletion requires higher authority than simple trashing.
Additionally:
Quotes with associated invoices cannot be permanently deleted until all related invoices are removed. Paid invoices can never be deleted, until unlocked and marked as unpaid.
This rule is enforced at system level.
📊 Reports & Data
export_reports≥view_reportsbackup_restore≥backup_create
This ensures:
- Exporting data requires visibility of reports.
- Restoring backups requires authority to create backups.
📈 Dashboard & Permissions
view_dashboard_stats≥view_dashboardmanage_access≥view_permissions
This ensures:
- Users viewing dashboard statistics must be able to access the dashboard.
- Anyone managing permissions must be able to view the permissions tab.
⚠ Soft Warning Rules
JiffyTrade includes logic warnings if you configure permissions inconsistently.
Examples:
- Setting
manage_xlower thanview_x - Setting tab-level manage permissions lower than
manage_settings - Granting advanced actions without foundational visibility
These warnings do not automatically override your configuration —
but they highlight potentially unsafe or illogical setups.
🔐 System-Level Enforcement vs UI-Level Control
It’s important to understand:
Even if a button is hidden in the UI, the capability is still enforced server-side.
This means:
- Actions cannot be triggered via direct URL access.
- Permissions cannot be bypassed via manual requests.
- Financial safeguards are enforced beyond the interface.
RBAC operates at logic level, not just display level.
🎯 Why the Hierarchy Matters
Without structured hierarchy:
- A user might be able to permanently delete without restoring
- A user might mark invoices as paid without issuing them
- A user might export financial data without viewing reports
The capability chain prevents contradictory authority.
