Custom code stores supported CSS and JavaScript snippets without editing the module's distributed files. Use it for deliberate customizations after checking whether the normal design or translation settings already meet the need.
IN THIS ARTICLE
01 Choose the correct scope
The workspace provides separate customer CSS, customer JavaScript, administrator CSS and administrator JavaScript snippets. Customer snippets load across the WHMCS client area as well as the module's pages and website portal. A selector or script that is too broad can therefore affect checkout and account forms.
02 Add and test a small change
- Save a copy of the currently working snippets and describe the intended change.
- Open Workspace > Custom code and choose the relevant snippet.
- For CSS, scope rules to the intended module surface. Use supported design variables where practical instead of overriding many unrelated elements.
- For JavaScript, use the documented
NHScontext and events when they fit the task. Check the active scope, page or section before acting. - Select Save custom code. Resolve reported syntax or brace errors before proceeding.
- Reload a test page and verify the change, browser console and important forms. Test the portal and mobile layout if the snippet applies there.
03 Keep custom code safe to maintain
Only add code you understand and trust. Browser JavaScript can read data available on the page, so do not paste unknown analytics, remote scripts or credential-handling code into a customer-wide snippet. Do not place API keys or private server credentials in client code.
Use a narrow selector such as the appropriate module root or website-manager section. Avoid changes that hide error messages, remove approval controls or make a disabled action appear usable. Styling cannot grant a missing provider capability.
How can I recover the administrator workspace after a custom-code error?
If administrator custom code makes the workspace unusable, add &nhs_safe=1 to the module's administrator URL where it already has query parameters. Safe mode opens the administration area without those custom snippets so you can inspect and correct them.
Remove the problematic snippet or restore the saved working copy, save, then reload the normal address. Confirm the underlying issue is fixed before continuing other configuration work.
04 Review after upgrades
Stored snippets survive module updates, but an updated page structure can change how a selector or event-dependent script behaves. Recheck your customizations after upgrading the module or WHMCS theme. Keep an internal change record with the purpose, author and tested surfaces, and remove obsolete overrides instead of allowing them to accumulate indefinitely.