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:

     $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));
     }
CommentFileSizeAuthor
#2 smsframework-515700.patch2.47 KBfw_crocodile

Comments

fw_crocodile’s picture

I think it would be better to integrate with trigger module.

As to have a trigger that let you do some action on number activation. This would be a lot more usefull.

fw_crocodile’s picture

Title: Change user role on sms activation » Add new trigger on Code validation
StatusFileSize
new2.47 KB

Hi,

this is a patch that created a new trigger on code validation. Note no actions id are registered to the trigger so you need to use the triggerunlock module.

You just have to create an action to change user role and apply it to the trigger.

Beware, the patch contain the #661134: Add "receive sms" permission. change too.

BenK’s picture

Subscribing...

univate’s picture

Status: Active » Needs review
grub3’s picture

You may look also at this issue: http://drupal.org/node/864326
I updated the patch.

dpi’s picture

Issue summary: View changes
Status: Needs review » Closed (outdated)