DocumentationAPI v1 · 1.3.0

Packages

WordPress plugin

Labyrinthe Connect WordPress plugin: SMS login, verification at sign-up and checkout, WooCommerce order SMS, webhooks and filters.

No-code plugin for WordPress 6.4+ and PHP 8.1+ (WooCommerce 8.0+ optional, HPOS and block checkout compatible). It bundles the PHP SDK.

Version 1.2.0. Source code, examples and changelog: wordpress folder on GitHub.

Installation#

  1. Plugins > Add New, search "Labyrinthe Connect", or upload labyrinthe-connect.zip (published in the repository's wordpress folder).
  2. Activate the plugin, then open Labyrinthe Connect > Settings (General, WooCommerce, OTP tabs).
  3. Paste the API key (stored encrypted), then Test the connection and Send a test SMS.

wp-config.php constants take priority over the settings:

WordPress
// wp-config.php
define( 'LABYRINTHE_CONNECT_API_KEY', 'lsk_test_xxxxxxxxxxxxxxxx' );
define( 'LABYRINTHE_CONNECT_WEBHOOK_SECRET', 'whsec_from_the_client_area' );
// define( 'LABYRINTHE_CONNECT_BASE_URL', 'http://localhost:8000' );

Features#

  • SMS login on wp-login.php and WooCommerce My Account (account found through the labyrinthe_phone meta, administrators refused unless enabled).
  • Phone verification at sign-up (WordPress and WooCommerce) and checkout (classic and blocks).
  • WooCommerce order SMS: one template per status, shop-manager SMS on each new order, background sending (Action Scheduler), Idempotency-Key per order and status, order notes.
  • SMS log (masked numbers, daily purge) and Web OTP enabled with the site domain.

Shortcode and block#

WordPress
[labyrinthe_otp_login redirect="/mon-compte/" title="Connexion par SMS"]

The labyrinthe-connect/otp-login Gutenberg block ("SMS login") has the same redirect and title attributes.

Order SMS variables#

{order_number} {order_id} {order_status} {order_total} {order_date} {order_url} {payment_method} {customer_name} {customer_first_name} {customer_phone} {shop_name} {shop_url} {tracking_number} {tracking_url}

Webhooks#

Declare the URL https://your-site/wp-json/labyrinthe/v1/webhook in the client area. The plugin checks the signature (5 min tolerance), deduplicates on id, updates the log and order notes, then fires actions:

WordPress
// $envelope = [ 'id' => …, 'event' => …, 'data' => [ … ], 'timestamp' => … ]
add_action( 'labyrinthe_message_status_changed', function ( array $envelope, ?array $row ) {
    error_log( $envelope['data']['message_id'] . ' is ' . $envelope['data']['status'] );
}, 10, 2 );

add_action( 'labyrinthe_otp_verified', fn ( array $envelope ) => null );
add_action( 'labyrinthe_balance_low', fn ( array $envelope ) => null );
// Also: labyrinthe_webhook_received, labyrinthe_otp_failed, labyrinthe_campaign_completed, labyrinthe_webhook_test_ping

Filters#

WordPress
// Skip the SMS for some orders
add_filter( 'labyrinthe_connect_send_order_sms', function ( bool $send, WC_Order $order, string $status ) {
    return $send && $order->get_total() > 0;
}, 10, 3 );

// Add a template variable
add_filter( 'labyrinthe_connect_order_sms_variables', function ( array $vars, WC_Order $order, string $status ) {
    $vars['{pickup_code}'] = $order->get_meta( '_pickup_code' );
    return $vars;
}, 10, 3 );

// Every SMS body, before sending
add_filter( 'labyrinthe_connect_sms_body', fn ( string $body, array $meta ) => $body, 10, 2 );

// After each send
add_action( 'labyrinthe_connect_sms_sent', fn ( array $result, array $meta ) => null, 10, 2 );
FilterRole
labyrinthe_connect_order_sms_bodyFinal text of an order SMS.
labyrinthe_connect_tracking_url, labyrinthe_connect_order_totalValues of {tracking_url} and {order_total}.
labyrinthe_connect_otp_login_user, labyrinthe_connect_otp_login_allowedFind the user of a number, allow their login.
labyrinthe_connect_web_otp_domainWeb OTP domain ('' disables it).
labyrinthe_connect_webhook_tolerance, labyrinthe_connect_client_ipWebhook tolerance, visitor IP (proxy).
labyrinthe_connect_delivery_order_notes, labyrinthe_connect_base_urlDelivery notes, API URL.

Maintenance and test mode#

  • Feature turned off (FEATURE_DISABLED): visitors see the platform message and the expected return date; order SMS are rescheduled (after Retry-After, otherwise 5, 10 then 15 minutes) with an order note.
  • Account suspended: admin notice with the request ID.
  • lsk_test_… key: nothing is sent; only administrators see the test OTP code, and order notes say so.

The plugin exposes no public PHP send function: use the actions and filters above, or install the PHP SDK for custom sending.