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
| Parameter | Type | Description |
|---|---|---|
$length | int | The OTP length (default varies) |
Constraints
The length must be an integer between 2 and 10. Values outside this range will throw an InvalidArgumentException.
| Min | Max | Default |
|---|---|---|
| 2 | 10 | 4-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
Related
- OTP Rate Limiter - Limit OTP request frequency
- wp_sms_otp_generated - Action hook when OTP is generated
Last updated: December 23, 2024