Project brief:
On a FreelanceEngine-based site, users who register as freelancers are able to access Dokan but do not receive the full vendor capabilities/rights. The client requested that the role freelancer be given all Dokan vendor rights while remaining a freelancer; and that the opposite also work — when a vendor registers they should also receive freelancer rights.
Why CnEL India was the right team
- WordPress & Marketplace expertise — deep experience integrating themes (FreelanceEngine) with marketplace plugins (Dokan/WooCommerce) and resolving role/capability mismatches safely.
- Security-first approach — we treat capabilities as a security boundary and perform changes so they are auditable and reversible.
- Reliable delivery — we provide both a production-safe implementation and a developer-friendly rollback/testing plan.
- Clear documentation & support — every code change is delivered as a small plugin or mu-plugin with comments and an uninstall/rollback path.
Challenge
The site uses two distinct user flows and roles: freelancer (from FreelanceEngine) and Dokan’s vendor. By default these roles have different capabilities. The requirement was to ensure both roles have the capabilities necessary to act as a Dokan vendor and to remain functional as a freelancer — and that the mapping works both ways without elevating privileges for unexpected roles (least privilege principle).
Objectives
- Grant the freelancer role the capabilities required by Dokan vendors (product management, store management, order management, etc.) while preserving freelancer-specific capabilities.
- Grant the Dokan vendor role the capabilities needed for freelancers (profile/portfolio, access to freelance-specific pages or custom post types) so vendors may also use freelance features.
- Make the change reversible, testable, and safe for production (no direct theme edits).
Solution overview
CnEL India implemented a small, self-contained plugin (or mu-plugin) that:
- Reads the capability sets on both roles at runtime (so the solution adapts to Dokan / site variations).
- Copies Dokan vendor capabilities to the
freelancerrole (if it exists) and copies freelancer capabilities to the Dokan vendor role. - Performs the change only if the roles are present and logs the operations for audit/rollback.
- Includes a safe uninstall/rollback routine and a short test checklist for administrators.
Technical implementation (code)
Install as a small plugin (recommended) or drop into wp-content/mu-plugins/. The code below safely attempts to locate common Dokan role slugs and copies capabilities bi-directionally. Place in a file such as cnel-sync-dokan-freelancer.php.
<?php
Notes about the code
- The plugin looks for the most common Dokan role slugs and common freelancer slugs — update the candidate arrays to match your site if you use custom slugs.
- It adds capabilities only (non-destructive) and writes an audit log into a WordPress option (
cnel_dokan_freelancer_sync_log), so you can inspect exactly what changed before making any rollback decisions. - If your site uses a Dokan Pro module or other plugins that add capabilities later, re-run the sync (visit
?cnel_sync=1as an admin) so newly added caps are copied. - We intentionally avoid removing caps automatically to prevent accidental privilege removal; if you want full reversible automation we provide a tested rollback script as part of delivery.
Testing & QA checklist (recommended)
- Create two staging users: one with the freelancer role, one with the Dokan vendor role.
- Activate the plugin on staging and either re-register or run the sync using
?cnel_sync=1while logged in as an admin. - From the freelancer account: verify vendor dashboard access, create a product, edit product, view/manage orders, and access Dokan store settings (store name, store settings, withdrawal request page if applicable).
- From the vendor account: verify freelancer-specific pages are accessible (profile, portfolio, or any custom freelance post types), can apply to freelance projects or create freelance listings if your theme uses them.
- Confirm that capabilities required only for admins are NOT added to these roles (e.g.,
manage_options, full plugin/theme editing capabilities). - Review the log stored at
cnel_dokan_freelancer_sync_logviaget_option()or a small admin page for audit.
Security & maintenance considerations
- Only grant the capabilities that Dokan actually needs. Our sync copies capabilities declared on the roles; review the capability list in the log and remove any capability you consider too privileged.
- Perform these changes on staging first and back up the database before running on production.
- Consider scheduling a re-sync after major plugin updates (Dokan releases new capabilities or modules).
- Track capability changes in a site-change log or within a staging/CI process.
Deliverables provided by CnEL India
- Small plugin file with commented code (as above) and activation/administration instructions.
- Rollback guidance and optional rollback script (manual verification step required before removal of caps).
- Test plan and a short QA report after running on staging.
- One week of post-deployment support to resolve edge cases or adjust capability lists.
Outcome & benefits
- Freelancers can now use Dokan vendor features (sell products, manage store settings, manage orders) without losing freelancer functionality.
- Sellers who register can access freelancer-specific flows, enabling a flexible hybrid marketplace (products + freelance services).
- Change is auditable, reversible, and implemented without modifying theme files — safe for future updates.
Favourable client review
“CnEL India delivered exactly what we needed: a secure, tested solution that allowed our freelancers to become full Dokan sellers while keeping their freelancer features intact. The team provided clear documentation, a neat plugin we could install on staging, and step-by-step testing guidance. Deployment on production was smooth and backed by responsive support. Highly recommended.”
Next steps (recommended)
- Run the plugin on staging and verify with the QA checklist above.
- Review the capability log and confirm no admin-level caps were copied accidentally.
- Push to production during a maintenance window and keep a DB backup handy.
- Optionally schedule a monthly sync after Dokan/plugin updates or enable a small admin UI to re-run the sync.
If you would like, CnEL India can deliver the plugin file, run the staging tests, and perform the production rollout with rollback safeguards included.
