Download & Extend

LoginToboggan breaks user_autorole (as well as numerous other things)

Project:User Autorole
Version:5.x-1.x-dev
Component:Documentation
Category:bug report
Priority:normal
Assigned:Unassigned
Status:active

Issue Summary

Just a search-indexable note to hopefully save someone else the trouble of spending an entire day troubleshooting a conflict that LoginToboggan creates with the user_autorole module as well as any other module which has a hook_user 'insert' operation.

Module downloaders beware... :-(

Comments

#1

This issue was raised in our issue queue for http://drupal.org/project/rolekey, but a quick assessment shows the problem appears to reside in the way this module inserts the roles. After this has been called, drupal deletes all roles assigned to the user and inserts the roles that reside in the $edit array.

The cause is that the module is manually inserting the user roles, when it should just be updating the roles key:

<?php
     
foreach ($roles_to_add as $role) {
       
watchdog('user_autorole', t('Adding role %role to new user %name.',  array('%name' => theme('placeholder'$edit['name']),  '%role' => theme('placeholder'$roles[$role]))), WATCHDOG_NOTICE);
       
db_query("INSERT INTO {users_roles} (uid, rid) VALUES (%d, %d)", $edit['uid'], $role);
       
//array_push($account['roles'], $role);
     
}
?>

to something like:
<?php

    
foreach ($roles_to_add as $role) {
       
watchdog('user_autorole', t('Adding role %role to new user %name.',  array('%name' => theme('placeholder'$edit['name']),  '%role' => theme('placeholder'$roles[$role]))), WATCHDOG_NOTICE);
       
$edit['roles'][$role] = $role;
      }

?>