wp_sms_sms_otp_length

Customize the length of OTP codes generated by WSMS.

The wp_sms_sms_otp_length filter allows you to customize the length of One-Time Passcodes (OTP) generated by WSMS.

Syntax

add_filter('wp_sms_sms_otp_length', 'your_callback');

Parameters

ParameterTypeDescription
$lengthintThe OTP length (default varies)

Constraints

The length must be an integer between 2 and 10. Values outside this range will throw an InvalidArgumentException.

MinMaxDefault
2104-6

Examples

Set 4-Digit OTP

add_filter('wp_sms_sms_otp_length', function($length) {
    return 4;
});

Set 6-Digit OTP

add_filter('wp_sms_sms_otp_length', function($length) {
    return 6;
});

Longer OTP for Higher Security

add_filter('wp_sms_sms_otp_length', function($length) {
    return 8;
});

Use Cases

  • Match OTP length with banking/financial standards
  • Shorter codes for better user experience
  • Longer codes for higher security requirements
  • Align with third-party integration requirements

Last updated: December 23, 2024