Verified,chang user role,relevance registration codes modules,field in views!

Events happening in the community are now at Drupal community events on www.drupal.org.
ai.30x's picture

Please help,I encountered the following problems:

When the user Verified mobile phone, how to change this user role?

How to modify the sms_user.module code?

How to use and relevance registration codes modules, because this modules easy control user role.

How to use mobile phone field in views?

SMS 6.x-1.0

Comments

The proper way, as I see it,

shushu's picture

The proper way, as I see it, would be to add an event (Rules module event) to the verification process.

I will look at it, and add it if possible to http://drupal.org/project/rules_send_sms

Setting role to a validated user

shushu's picture

Hi Ben,

First, please try not to ask so many questions at once. It is hard to give proper answers when they are together.
Second, here comes the solution to what you asked - setting a role to a user who validated its mobile number.

Since you wrote you worked on 6.x-1.0, the patch is for this version.

--- modules/sms_user/sms_user.module    2010-07-25 18:53:27.000000000 +0000
+++ /var/www/sites/all/modules/smsframework/modules/sms_user/sms_user.module    2010-07-25 18:59:24.000000000 +0000
@@ -159,7 +159,9 @@ function sms_user_settings_confirm_form(
function sms_user_settings_confirm_form_validate($form, &$form_state) {
   if ($form_state['clicked_button']['#value'] == t('Confirm number')) {
     $account = user_load(array('uid' => arg(1)));
-    if ($form_state['values']['confirm_code'] != $account->sms_user[0]['code']) {
+    if ($form_state['values']['confirm_code'] == $account->sms_user[0]['code']) {
+      rules_invoke_event('sms_user_verified', $account);
+    } else {
       form_set_error('confirm_code', t('The confirmation code is invalid.'));
     }
   }
@@ -497,3 +499,19 @@ function sms_user_logout() {
   session_destroy(); 
   $user = drupal_anonymous_user();
}
\ No newline at end of file
+
+/
+
Implementation of hook_rules_event_info().
+* @ingroup rules
+ */
+ function sms_user_rules_event_info() {
+  return array(
+    'sms_user_verified' => array(
+      'label' => t('User validated SMS code'),
+      'module' => 'SMS',
+      'arguments' => array(
+        'user' => array('type' => 'user', 'label' => t('Validated user')),
+      ),
+    ),
+  );
+}

To implement this patch, copy its content to a patch.txt file, put the file in your relevant directory (where your modules directory exist), and do patch -p0 < patch.txt

Next, you can create a rule that is being triggered using the "sms_user_verified" event.
Here is an example of a rule you can import - in this case, it checkes the user does not have the role (role id 4, verify you have such a role) before setting it.

<?php
array (
 
'rules' =>
  array (
   
'rules_52' =>
    array (
     
'#type' => 'rule',
     
'#set' => 'event_sms_user_verified',
     
'#label' => 'sms validation',
     
'#active' => 1,
     
'#weight' => '0',
     
'#categories' =>
      array (
      ),
     
'#status' => 'custom',
     
'#conditions' =>
      array (
       
0 =>
        array (
         
'#settings' =>
          array (
           
'roles' =>
            array (
             
0 => 4,
            ),
           
'operation' => 'OR',
           
'#argument map' =>
            array (
             
'user' => 'user',
            ),
          ),
         
'#type' => 'condition',
         
'#name' => 'rules_condition_user_hasrole',
         
'#info' =>
          array (
           
'label' => 'User has role(s)',
           
'arguments' =>
            array (
             
'user' =>
              array (
               
'type' => 'user',
               
'label' => 'User',
              ),
            ),
           
'module' => 'User',
          ),
         
'#weight' => 0,
         
'#negate' => 1,
        ),
      ),
     
'#actions' =>
      array (
       
0 =>
        array (
         
'#weight' => 0,
         
'#info' =>
          array (
           
'label' => 'Add user role',
           
'arguments' =>
            array (
             
'user' =>
              array (
               
'type' => 'user',
               
'label' => 'User whos roles should be changed',
              ),
            ),
           
'module' => 'User',
          ),
         
'#name' => 'rules_action_user_addrole',
         
'#settings' =>
          array (
           
'roles' =>
            array (
             
0 => 4,
            ),
           
'#argument map' =>
            array (
             
'user' => 'user',
            ),
          ),
         
'#type' => 'action',
        ),
      ),
     
'#version' => 6003,
    ),
  ),
)
?>

Proper issue and patch attached.

Regards,
Shushu

Thank you ! You are great,I

ai.30x's picture

Thank you !

You are great,I learned a lot

====================================================================
Using the symbols interpretation of the real, using the model interpretation of the truth.

SMS Framework

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: