In WP SMS, ensuring the validity of users’ mobile numbers is crucial to maintaining data integrity and ensuring successful SMS communication. This document outlines how to use the checkMobileNumberValidity function and modify its behaviour using hooks.
Hook Modification
You can modify the behaviour of the mobile validity check by using the wp_sms_mobile_number_validity
filter. Here’s an example:
add_filter('wp_sms_mobile_number_validity', 'custom_mobile_number_validity', 10, 2);
function custom_mobile_number_validity($isValid, $mobileNumber) {
// Add custom validation logic here
if (/* custom condition */) {
return new WP_Error('custom_invalid_number', __('Custom error message', 'wp-sms'));
}
return $isValid;
}