Embedding the ticket form on another site

Home » Developers » Embedding the ticket form on another site

NiroHelp serves a self-contained “Need Help?” ticket widget from
/nirohelp/tickets/embed/. It is a JavaScript file, not a page — the
endpoint responds with Content-Type: application/javascript, so you load it
with a <script> tag, not an iframe.

The widget adds a floating launcher to the host page and opens a new-ticket
form. It is a submission surface only: there is no login, no ticket list and no
conversation thread inside it. For those, use the shortcodes on your own site.

The snippet #

<script src="https://help.example.com/nirohelp/tickets/embed/" defer></script>

The trailing slash matters — /nirohelp/tickets/embed (no slash) answers with
a 301 to the slashed form, which a <script src> does follow, but the rewrite
rule the plugin registers is ^nirohelp/tickets/embed/?$, so link the canonical
URL.

Drop it on any page on any site, WordPress or not.

What the visitor sees #

A pill-shaped Need Help? button pinned to the bottom-right of the page.
Clicking it opens a panel containing:

Field Required Notes
Your Name yes Used for the client account and for ##client_name##.
Your Email yes Resolves to an existing account, or creates one.
Subject yes Becomes the ticket title.
Description yes Becomes the ticket body.
Product no Populated from GET /tickets/products/.
Reason no Populated from GET /tickets/reasons/.
Urgency no Populated from GET /tickets/urgencies/.
Order ID no Stored as the order post meta.

Submitting posts to POST /wp-json/nirohelp/v1/tickets/ on the site that
served the script. That route is deliberately open to anonymous callers — the
widget runs cross-origin and cannot carry a wp_rest nonce — and hardened
inside the callback instead: an anonymous caller can never set user_id, so a
ticket is always filed against the account resolved from the submitted email.

Where the site URL comes from #

The endpoint prints one line ahead of the static file:

var NIROHELP_HOME_URL = "https://help.example.com";

That is what the widget calls. If you serve the script some other way (copying
assets/tickets/js/embed.js to a CDN, say), the script falls back to slicing
its own src at /wp-content/ or /nirohelp/tickets/embed, and finally to
window.location.origin. Loading it from a third host without either marker in
the path will point it at the wrong site.

Account creation is a prerequisite #

A submission from an email with no matching WordPress user only succeeds when
account creation is allowed — core’s Anyone can register, or NiroHelp ->
Settings -> Tickets -> Submission -> Create accounts for new clients
. With
both off, the widget can only accept tickets from people who already have an
account on the help site.

How it differs from the shortcodes #

Embed widget [nirohelp_new_ticket]
Runs on any site the WordPress site hosting NiroHelp
Rendering injected by JS, ignores your theme inside your theme
Fields fixed set above driven by Settings -> Tickets -> Form fields, custom fields included
Login none; identifies by email login required, honours the configured login method
Reading replies not possible via [nirohelp_tickets] and the emailed login link

The widget is the “let people file a ticket from our marketing site” surface.
Clients still read and answer their tickets on the help site, through the link
in the notification email.

Styling it #

The widget writes inline styles and has no configuration attributes. To change
its appearance, copy assets/tickets/js/embed.js into your own theme or
plugin, edit it there, and enqueue your copy instead of the endpoint. Keep
NIROHELP_HOME_URL defined ahead of it, or leave the file at a path containing
/wp-content/ so the fallback resolves.

Disabling the endpoint #

The rewrite rule is registered unconditionally. To take the endpoint offline
without editing the plugin, short-circuit it before template_include runs:

add_action( 'template_redirect', function () {
    if ( get_query_var( 'nirohelp_tickets_embed' ) ) {
        status_header( 404 );
        exit;
    }
}, 5 );

Was this doc helpful?

Scroll to Top