It does not assign new users to a designated role, though I am sure for 100% that I correctly typed the name of the role in the module's settings. Could this module have a conflict with other modules? I use acl to make private forums, for example.

Comments

pmcka’s picture

I'm having the same problem. It seems to happen after adding Login Toboggan.

matchu’s picture

Title: It does not assign new users to a designated role » Does not auto-assign new users a designated role
Priority: Normal » Critical

This module does not auto-assign roles to new users.

jscheel’s picture

Status: Active » Needs review
StatusFileSize
new820 bytes

Ok, I've attached a patch that seems to fix the problem. Just updates the roles when the user is updated.

greggles’s picture

Status: Needs review » Needs work

@jscheel - it seems like you stumbled on a couple problems:

1) when editing a user you want the autoassignrole to be assigned. I'm not sure that's the correct behavior.
2) There is a possibility created by your change that now a user will already have that role which causes a db error.

This module works fine for me for normal users creating accounts, so I guess there must be another problem.

First, please note that it can't assign roles for users created by the admin (as the "known problems" on the front page of the site mentions.

Beyond that, I can only imagine that there is a module conflict of some sort. Can folks try disabling individual modules and see if that changes the situation?

yngens’s picture

After reading pmcka's post I had to gave up Login Toboggan in order to be able to use Auto Assign Role. For some reason they indeed do not work together.

jscheel’s picture

Ok, I took another look at this. It doesn't make sense to set the user's role when they edit their profile. However, as a safeguard, why not assign the role when the user logs in? You won't get a database error because the SQL uses "ON DUPLICATE" to handle duplicate entries. This will also make it easy to mass modify the accounts. Let's say 2 months into your website, you realize that you want all registered users to automatically be assigned the "member" role. Then you just have to make the role, set it up to be autoassigned and the next time an existing user logs in, they will get the role, just like new users will.

jscheel’s picture

Status: Needs work » Needs review
StatusFileSize
new847 bytes

Ok, attached a quick patch for my comment above.

jscheel’s picture

StatusFileSize
new1.19 KB

After talking to greggles, the above patch seems rather silly. This new one will only assign the role at login if it is the first time the user has ever logged in.

greggles’s picture

I'd still rather figure out why the module doesn't work consistently for new users. It works fine in my testing, so it must either be based on a different workflow (i.e. using a different signup form) or a conflict in different modules.

However, this approach seems much more reasonable to me and as a reasonable alternative to finding the root problem it could be the best solution.

jscheel’s picture

I think part of the problem is how the user signs in the first time. It looks like users who use the "one-time login" link don't get assigned roles. This may be a symptom of logintoboggan/autoassignrole's compatibility issues. Can anyone else verify? I don't have time right now.

9802008’s picture

Thanks for the handy module!

I do have logintoboggan and auto assign role installed and experience the same problem. Using devel I see that the correct role is allocated with a db_query:

0.1 1 autoassignrole_user INSERT INTO users_roles (uid, rid) values (22, 7)

however a few lines later user_save () function runs this query:

0.1 1 user_save DELETE FROM users_roles WHERE uid = 22

I don't get why it does that. The patch autoassignrole_161170_0.patch fixes the problem for me when the user logs in.

jscheel’s picture

Status: Needs review » Needs work

Hmm, I've come across another problem. In my patch above, I check the user->access to see if the user has ever logged in, so that their role isn't reset every time they log in. This doesn't work if the user is modified by the admin before they login, because their access time is modified.

For right now, if you modify a user before they ever log on, you have to set their role manually.

cyberswat’s picture

Assigned: Unassigned » cyberswat
Status: Needs work » Fixed
Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.