How can I attach a phone number field to the user account and optionally validate it via SMS? 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:


Verification code when adding new number
Cell phone validation using SMS message
To address the modules mentioned:


This is a non-starter as it's a different use case from SMS number verification. 
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' =&gt; TWILIO_USER_CONFIRMED, in the $edit array. In either case, you'd have to build/evoke your own custom rules event.
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).