
Admin settings page with all configuration options
OneCode Login provides a modern, passwordless authentication experience for your WordPress site. Instead of traditional passwords, users receive a secure 6-digit verification code via email.
Other plugins on the same site can use OneCode Login as a generic email
one-time-code (OTP) service — for example to verify a guest’s email before
letting them act. OneCode emails the code and verifies it; your plugin keeps
full control of its own login/session (OneCode only asserts that the code is
valid for the email — it never logs anyone in). It works for any email
address; the address does not need a WordPress account.
All entry points are plain functions (and matching filters), so you do not need
a hard dependency on any class. The API is gated by the Settings Advanced
Enable developer API toggle.
Detect support (side-effect free — never call the request hook just to probe):
if ( function_exists( 'onecode_login_request_otp' ) && onecode_login_supports( 'otp' ) ) { ... }
Start authentication — email a code and receive a handle:
$handle = onecode_login_request_otp( $email, array( ‘consumer’ => ‘my_plugin’ ) );
// $handle = array( ‘request_id’, ‘auth_secret’, ‘expires_in’ (seconds), ‘expires_at’ (UTC), ‘sent’ )
// On failure: a WP_Error (codes: disabled, invalid_request, rate_limited, cooldown).
Keep request_id and auth_secret server-side (e.g. in a transient tied to the
visitor). The auth_secret is NEVER shown to the customer — it is what stops an
outsider who only knows the email from completing verification by guessing codes.
Complete authentication — the customer gives your plugin the code from the email:
$result = onecode_login_verify_otp( array(
’email’ => $email,
‘request_id’ => $handle[‘request_id’],
‘code’ => $code_from_customer,
‘auth_secret’ => $handle[‘auth_secret’],
‘consumer’ => ‘my_plugin’,
) );
// Success: array( ‘valid’ => true, ’email’ => … ). Failure: WP_Error.
On failure show a generic message to the user (the API intentionally returns a
single verify_failed code so it can’t be used as an oracle).
Filters are also available for loose coupling: onecode_login_request_otp
($pre, $email, $args) and onecode_login_verify_otp ($pre, $args).
Discovery and capabilities:
onecode_login_supports( $feature ) — returns true for 'otp','any_email'.onecode_login_api() — returns the OneCode_Login_API service instance.OneCode_Login_API::VERSION — the API contract version (independent of thedo_action( 'onecode_login_api_init', $api ) — fires once the API is ready;Reference: $args['consumer'] (a short [a-z0-9_-] label identifying your
integration) is required on both calls — it isolates your codes and rate limits
from the built-in login and from other consumers. Both request and verify are
rate-limited by OneCode, returning rate_limited / cooldown WP_Errors you can
surface to the user.