Skip to content

Settings & Developers

QRify Developer Hooks, Capability and REST API

Need to send paused codes to a fallback page, push every scan into your CRM, add a country from your own CDN header, or create codes from a script? QRify exposes four filters, four actions, a dedicated capability and a qrify/v1 REST API. This page lists each one with its exact signature, taken from the plugin source.

What can developers extend in QRify?

QRify provides WordPress filters to change what a scan does (qrify_scan_target), where inactive codes go (qrify_inactive_redirect), what counts as a bot (qrify_is_bot) and which country a scan is from (qrify_scan_country). Actions fire after a counted scan and when codes are created, updated or deleted. Access is controlled by the manage_qrify capability.

All examples below go in a small custom plugin or your theme's functions.php.

Filters

qrify_scan_target

Changes what a dynamic code does when scanned, after the scan has been counted.

apply_filters( 'qrify_scan_target', array $target, array $code );

$target has an action key:

action Other keys Used by
redirect url Website, File / PDF, WhatsApp, Email, Phone, SMS, Location
download mime, filename, body Contact (vCard .vcf), Event (.ics)
page text Text — shown on a minimal page

Redirects are always 302 and only to http, https, mailto, tel or sms URLs; any other scheme shows "QR code not found".

Example — add a UTM source to every website code's destination:

add_filter( 'qrify_scan_target', function ( $target, $code ) {
	if ( 'url' === $code['type'] && 'redirect' === $target['action'] ) {
		$target['url'] = add_query_arg( 'utm_source', 'qr', $target['url'] );
	}
	return $target;
}, 10, 2 );

qrify_inactive_redirect

By default, a paused, expired or scan-limited code shows a status page. Return a URL to redirect there instead (302). Return '' to keep the status page.

apply_filters( 'qrify_inactive_redirect', string $url, array $code );
add_filter( 'qrify_inactive_redirect', function ( $url, $code ) {
	return home_url( '/offer-ended/' );
}, 10, 2 );

See Pause, expire or limit a QR code for when a code becomes inactive.

qrify_is_bot

Decides whether a request is a crawler or link preview. Bot requests are still served but not counted.

apply_filters( 'qrify_is_bot', bool $is_bot, string $ua );

QRify's built-in check treats an empty user agent, and user agents matching terms such as bot, crawl, spider, facebookexternalhit, whatsapp, telegram, slack, discord, preview, curl, wget, headless, lighthouse, pingdom, uptime and monitor, as bots.

add_filter( 'qrify_is_bot', function ( $is_bot, $ua ) {
	return $is_bot || false !== stripos( $ua, 'MyInternalChecker' );
}, 10, 2 );

qrify_scan_country

Supplies or overrides the scan's country. Return an ISO 3166-1 alpha-2 code (two uppercase letters) or ''.

apply_filters( 'qrify_scan_country', string $country );

QRify passes in the value from CF-IPCountry (Cloudflare), CloudFront's viewer-country header, X-Country-Code, or GEOIP_COUNTRY_CODE — whichever is set first — and makes no lookups of its own. Values that aren't two letters, plus XX and T1, are discarded.

add_filter( 'qrify_scan_country', function ( $country ) {
	if ( '' === $country && ! empty( $_SERVER['HTTP_X_MY_CDN_COUNTRY'] ) ) {
		$country = strtoupper( sanitize_text_field( wp_unslash( $_SERVER['HTTP_X_MY_CDN_COUNTRY'] ) ) );
	}
	return $country;
} );

See QR code scan analytics.

Actions

Action Arguments Fires
qrify_scanned array $code After a human scan of a dynamic code is counted, before the visitor is redirected. Not fired for bots or ignored admin scans.
qrify_code_created int $id After a code is created — from the editor, Duplicate, bulk import or the REST API.
qrify_code_updated int $id After a code is saved.
qrify_codes_deleted int[] $ids After one or more codes and their scans are deleted.

Example — notify an external system on every scan:

add_action( 'qrify_scanned', function ( $code ) {
	wp_remote_post( 'https://example.com/hooks/qr-scan', array(
		'blocking' => false,
		'body'     => array(
			'code_id' => $code['id'],
			'slug'    => $code['slug'],
			'title'   => $code['title'],
		),
	) );
} );

Keep qrify_scanned callbacks fast and non-blocking: they run inside the redirect, so a slow callback delays every scan. The $code array is loaded before the scan is counted, so its scan_count doesn't yet include this scan.

The $code array

Hooks that receive a code get these keys: id, title, type, is_dynamic, slug, prefix, content, design, status (active or paused), expires_at (site time), expires_gmt, scan_limit, scan_count, created_by, created_at, updated_at.

Types are url, text, email, phone, sms, whatsapp, wifi, vcard, event, geo and file. See QR code types.

The manage_qrify capability

Every QRify admin screen and REST route requires the manage_qrify capability. QRify adds it to the Administrator role when the plugin is activated.

To let another role manage QR codes, add the capability once — for example, on a one-off admin request or in an activation routine:

$role = get_role( 'editor' );
if ( $role ) {
	$role->add_cap( 'manage_qrify' );
}

The Ignore my own scans setting skips scans from any logged-in user with this capability.

REST API (qrify/v1)

QRify's admin app runs on a REST API under /wp-json/qrify/v1. Every route except /lookup requires manage_qrify and an active QRify licence; without a licence they return 403 qrify_unlicensed. Cookie-authenticated requests need the standard wp_rest nonce.

Method Route Purpose
GET /codes List codes. Args: search, type, status, page (1), per_page (20), orderby (created_at), order (DESC).
POST /codes Create a code. Body: title, type, is_dynamic, slug, content, design, status, expires_at, scan_limit.
GET /codes/{id} Get one code.
POST/PUT/PATCH /codes/{id} Update a code.
DELETE /codes/{id} Delete a code and its scans.
POST /codes/{id}/duplicate Duplicate a code.
POST /codes/bulk action: delete, pause, activate or apply_template (with template); ids: up to 500.
POST /codes/import Create up to 50 codes of one type from rows; dynamic (default true), optional template.
GET/POST /templates List or create design templates.
POST /templates/default Set the default template.
POST/PUT/PATCH, DELETE /templates/{id} Update or delete a template.
POST /preview Render a preview SVG.
GET /slug Check whether a slug is available; exclude a code ID.
GET /stats Analytics for code_id (0 = all) over days (default 30).
GET /stats/export The same range as CSV data.
GET, POST/PUT/PATCH /settings Read or save settings.
GET /lookup Search active codes by search for the block's picker. Requires edit_posts.

Every field is validated server-side, so invalid content returns a WP_Error with a message rather than saving a broken code.

Example — list codes from WP-CLI without an HTTP request (run as an administrator, user ID 1 here):

wp eval 'wp_set_current_user( 1 ); $r = rest_do_request( new WP_REST_Request( "GET", "/qrify/v1/codes" ) ); print_r( $r->get_data() );'

Front end is never licence-gated

The licence gates the admin screens and this API only. Short-link redirects, the [qrify] shortcode and the QR Code block keep working if a licence lapses, so printed codes never stop working because of a renewal.

Conclusion

Use the filters to shape what a scan does, the actions to react to scans and code changes, and the REST API to manage codes from scripts. For front-end output, see the [qrify] shortcode and the QR Code block.

FAQs

How do I redirect expired QR codes to another page?

Use the qrify_inactive_redirect filter and return the URL to send visitors to. It runs for paused, expired and scan-limited codes, receives the code array, and redirects with a 302. Return an empty string to keep QRify's default status page.

Can I run code every time a QR code is scanned?

Yes. Hook into the qrify_scanned action, which receives the code array after a human scan is counted. It doesn't fire for bots, link previews or ignored admin scans. Keep the callback fast, because it runs before the visitor is redirected.

How do I let editors manage QR codes?

Give the role the manage_qrify capability, for example with get_role( 'editor' )->add_cap( 'manage_qrify' ). QRify only grants it to administrators on activation. The capability controls every QRify screen and REST route.

Does the QRify REST API work without a licence?

No. Every management route returns a 403 qrify_unlicensed error until the licence is active. Short-link redirects, the shortcode and the block are not gated and keep working regardless of licence state.

Is there a REST endpoint to create QR codes in bulk?

Yes. POST /wp-json/qrify/v1/codes/import creates up to 50 codes of one type per request from a rows array, optionally as dynamic codes with a design template. The bulk import screen uses the same endpoint, sending larger files in batches of 50.

Was this page helpful?