2

On my site, after registering their account, I want users to optionally be able to go to their account page, input a phone number, and then verify that number by SMS. When they verify the phone number, I want to award a special role (ideally via Rules).

It seems like there are several modules that might be able to do this:

  • Two-factor authentication-- this supports SMS with the TFA Basic plugins, but I don't want to use SMS for authentication, just once to verify the number.
  • Twilio-- this module has user phone number verification, but it does it in a special database table (not a Drupal field) and does not have a rules event for "when a number is verified."
  • SMS Framework-- this module contains a submodule ("SMS Framework Users") for phone number verification, but it only works on registration; there is no option to register a number later (and in my case, I do not want to collect numbers on registration; I want to collect numbers later optionally).

Related questions:

3 Answers 3

1

To address the modules mentioned:

  1. This is a non-starter as it's a different use case from SMS number verification.
  2. Here you'd have to build off the back the Twilio module. You could modify user setting form twilio_user_settings_form() so that the callback twilio_user_settings_confirm_form_submit() is altered with your own custom callback that triggers a callback. Alternatively, you could evoke a hook_user_presave() as twilio_user_settings_confirm_form_submit calls user_save() with 'status' => TWILIO_USER_CONFIRMED, in the $edit array. In either case, you'd have to build/evoke your own custom rules event.
  3. The SMS User module does provide verification for existing users. The form can be found under the path user/{UID}/edit/mobile. It triggers User validated SMS code event once the user has completed the verification process.

Given the above, both modules can achieve what you're looking for, it's just a matter of how much modification vs. what each service provides (Twilio vs. any other SMS Gateway provider).

1
  • The benefit of using SMS Framework module is that once set up, the functionality is available no matter which gateway provider you are using. But then you would need to install the Twilio gateway module for SMS Framework (drupal.org/project/sms_twilio)
    – Alma
    Sep 9, 2017 at 13:30
1

I managed to do this with the Twilio module.

  1. First I applied a patch to get the "when a number is verified" rules event.
  2. The path for Twilio phone number verification is /user/UID/edit/twilio.
  3. The text strings in this module required heavy revision (English not quite accurate, lack of punctuation, etc.)

I then used Rules, Panels, Flag, and other modules to make a custom flow in which users are prompted to verify by SMS after registration.

0

You can do this with the Mobile Number module that I wrote. And using rules you can check the number was verified.

Mobile Number is a field type that provides mobile number validation and verification, and can be used for two factor authentication. It works with SMS Framework and TFA modules, respectively, and both features are optional.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.