Change user role on sms activation
kaerast - July 10, 2009 - 14:53
| Project: | SMS Framework |
| Version: | 6.x-2.x-dev |
| Component: | SMS User |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Description
Once a user has correctly entered the confirmation code to activate their mobile phone number, it would be nice to have them automatically added to a certain role. It could be done quite easily by adding some code after user_save in sms_user_settings_confirm_form_submit. In fact the following code achieves this, but is hard coded to a single role which is in use on one of my websites:
<?php
$rid = 6;
$role_name = db_result(db_query('SELECT name FROM {role} WHERE rid = %d', $rid));
if ($account !== FALSE && !isset($account->roles[$rid])) {
$roles = $account->roles + array($rid => $role_name);
user_save($account, array('roles' => $roles));
}
?>