I have run into a problem using this module. It was working ok up until today.

I use it on my registration to differentiate between a public and trade user. I am using core profile with no whistles and bells. I have set up auto assign role so it has to be filled out by the person registering and only one role can be chosen through a checkbox. Upon them registering and picking a role I check my users page in admin and they have been assigned both roles even though one role was checked on registration. I have restored my database and site to try and remedy the problem but had no joy.

I had been messing around with various other modules this morning associated with the user profile and password security but as I say, I have restored to a time when they weren't enabled and the problem seems to have transferred over. Any ideas to what could have happened or any solutions?

Comments

cyberswat’s picture

Have you tried to completely uninstall the module and reinstall it? Make sure to drop all the old tables it uses and do a clean install of it. I'm not sure what the problem could be off the top of my head due to the code not changing.

gillypots’s picture

I tried what you suggested and had no joy i'm afraid, it's still doing the same thing :(

cyberswat’s picture

@gillypots can you debug this a little more by stepping through the code? I would suspect the problem can be identified by looking at the insert op in autoassignrole_user() ... I'd be interested to see what _autoassignrole_get_settings('foo') is returning in your environment.

gillypots’s picture

Errr, wouldn't know where to start to give you that info, I have only been using drupal for a few weeks and am a total newbie, although learning quickly (am having too). Would I need to download a debug software to get that info? Any guidance on what to do would be appreciated!
Not sure if any of the info I give here will be of any relevance but just thought I would mention it just incase:

Am working on localhost through XAMPP.

I have installed a similar module, register_with_approval just to see if I would get the same outcome but that works fine, correctly registering the separate roles on registration. I would really like to get this sorted as the auto assign module is a lot better suited to what i'm after for my site than the register_with_approval module.

cyberswat’s picture

If you look in autoassign_role.module you will see a couple of lines similar to the following in autoassignrole_user()

$user_roles = _autoassignrole_get_settings('user_roles'); 

Inserting a print_r($user_roles); after each of those lines should show us what roles the user is being assigned when it is created. That can help us start narrowing down or reproducing what your seeing.

gillypots’s picture

I have looked in the autoassign_role.module file and "think" I have found the lines of code (lines 165, 221, 230, 239, 249, 260) and put the print_r($user_roles); directly after these lines. I tried a test registration, checking only one of my role checkboxes, when submitted a page came up saying:

Array ( [3] => 3 [4] => 4 ) Array ( [3] => 3 [4] => 4 ) Array ( [3] => 3 [4] => 4 )

Not a clue what that means or if that gives you a hint as to whats going on. Here's what I did to the code, sorry for the length, just thought it would be worth you looking to see if I had done it correctly as I am unsure:

if (_autoassignrole_get_settings('user_active') == 1) {
        $roles = array();
        $user_roles = _autoassignrole_get_settings('user_roles');
        print_r($user_roles);
        if (is_array($edit['user_roles'])) {
          foreach ($edit['user_roles'] as $k => $v) {
            if ($v != 0 && in_array($k, $user_roles, TRUE)) {
              $roles[$k] = $v;
              print_r($user_roles);
            }
          }
          $edit['roles'] = $roles;
        }
        elseif ($edit['user_roles'] != '') {
          $edit['roles'] = array($edit['user_roles'] => $edit['user_roles']);
        }
      }
      if ($rid = autoassignrole_get_active_path_rid()) {
        $edit['roles'][$rid] = $rolenames[$rid];
      }
      if (_autoassignrole_get_settings('auto_active') == 1) {
        $auto_roles = _autoassignrole_get_settings('auto_roles');
        foreach ($auto_roles as $k => $v) {
          $edit['roles'][$k] = $rolenames[$k];
        }
      }
      $account = user_load(array("uid" => $account->uid));
    break;
    case 'register':
      if (_autoassignrole_get_settings('user_active') == 1) {
        $roles = user_roles(TRUE);
        $user_roles = _autoassignrole_get_settings('user_roles');
        $path_roles = db_query("SELECT rid from {autoassignrole_page}");
        while ($path_role = db_fetch_object($path_roles)) {
          unset($roles[$path_role->rid]);
        }
        foreach ($roles as $k => $r) {
          if (!in_array($k, $user_roles, TRUE)) {
            unset($roles[$k]);
          }
        }
        if (count($roles)) {
         $form['autoassignrole_user'] = array(
           '#type' => 'fieldset',
           '#title' => _autoassignrole_get_settings('user_fieldset_title'),
           '#collapsible' => FALSE,
           '#collapsed' => FALSE,
         );
         if (_autoassignrole_get_settings('user_sort') == "SORT_ASC") {
           uasort($roles, '_autoassignrole_array_asc');
         }
         else {
           uasort($roles, '_autoassignrole_array_desc');
         }

         if (!$edit || !array_key_exists('user_roles', $edit)) {
           $edit['user_roles'] = array();
         }
         if (_autoassignrole_get_settings('user_selection') == 0) {
            print_r($user_roles); 
            $form['autoassignrole_user']['user_roles'] = array(
             '#type' => 'radios',
             '#title' => t(_autoassignrole_get_settings('user_title')),
             '#options' => $roles,
             '#description' => t(_autoassignrole_get_settings('user_description')),
           );
           
         }
         if (_autoassignrole_get_settings('user_selection') == 1) {
             print_r($user_roles);
             $form['autoassignrole_user']['user_roles'] = array(
             '#type' => 'select',
             '#title' => t(_autoassignrole_get_settings('user_title')),
             '#default_value' => '',
             '#description' => t(_autoassignrole_get_settings('user_description')),
           );
          
           if (_autoassignrole_get_settings('user_multiple')) {
             print_r($user_roles);
             $form['autoassignrole_user']['user_roles']['#multiple'] = TRUE;
             unset($form['autoassignrole_user']['user_roles']['#default_value']);
           }
           else {
             $roles[''] = '';
           }
           $form['autoassignrole_user']['user_roles']['#options'] = $roles;
         }
         if (_autoassignrole_get_settings('user_selection') == 2) {
             print_r($user_roles);
             $form['autoassignrole_user']['user_roles'] = array(
             '#type' => 'checkboxes',
             '#title' => t(_autoassignrole_get_settings('user_title')),
             '#default_value' => $edit['user_roles'],
             '#options' => $roles,
             '#description' => _autoassignrole_get_settings('user_description'),
           );
         }
         if (_autoassignrole_get_settings('user_required')) {
           print_r($user_roles);
           $form['autoassignrole_user']['user_roles']['#required'] = TRUE;
         }
         return $form;
        }
      }
    break;
  }
}
cyberswat’s picture

Sure ... basically what this is telling us is that the autoassignrole module is being told to assign role id 3 and role id 4 to the role based on settings that it has (or thinks it has) been given. It almost sounds like there is a configuration setting that was put in place to make this happen.

Can you hop on irc by any chance to discuss this? If not could you please remove the print_r()'s you added and place print_r($value) on the line after:
function _autoassignrole_get_settings($value) { so that we can see whic group of settings we are dealing with?

gillypots’s picture

Sorry, I dont have irc (didnt know what it was, had to google it) so i've just followed your instructions and have got rid of the print_r's and added the print_r($value) on the line you said.

it comes back with:

user_activeuser_rolesuser_fieldset_titleuser_sortuser_selectionuser_titleuser_descriptionuser_selectionuser_selectionuser
_requireduser_activeuser_rolesauto_activeauto_roles

liquidcms’s picture

Version: 6.x-1.1 » 6.x-2.0-beta1
Category: support » bug

just starting to set up this module and i am seeing the same issue.. more details:

- i use this for numerous roles
- i have a url for each specific role
- one of my roles was being used but i have now disabled it... BUT, that role and the others that are used with this are all assigned to my new user (but this is not ALL the roles i have; just the ones that are/were enabled for this at some point).. very odd

- use content profile with this to add various nodes to reg form

- bumped this to 2.0 beta as that is what i am using as i needed it to fix this issue #956360: Content Profile and Content Profile Registration errors - unclear if these issues are related.. but possibly.

also, i am not a drupal newbie.. :).. going through code now to sort out where the issue is coming from.

liquidcms’s picture

oops.. my bad.. just a config issue

i initially though that under the section Automatic Role Assignment - selecting the roles here was just defining which roles i could assign a role signup path to.. didn't realize that was over and above any role i assign as a result of the Assign from Path.

makes sense though..

Anonymous’s picture

I also have a problem of multiple roles assigned to a user.
I use assign from path for two roles :

inscription/role1
inscription/role2

if a user uses inscription/role1 the role assigned is only role1 but if a user uses inscription/role2, he has two roles : role1 and role2

Could this be a problem with Login tobogan or something else ? The paths are different even if they do have the same root.

I hope you can help me.

Thank you.

mike.davis’s picture

Issue summary: View changes
Status: Active » Postponed (maintainer needs more info)

This issue has been open for a long time now. Is it still an issue or has this been solved?

sarath.rajan’s picture

I am still getting this issue. Any help?

mike.davis’s picture

Status: Postponed (maintainer needs more info) » Active

Hi @sarath.rajan, thanks for the message.

Are you using login tobogan as well or any other modules that deal with registration?

Is your scenario similar to those detailed already?