I have a role called Authenticated +1. Which means, for 1 point, users belong to that role. I give users 1 point for registering. Now, they get the email saying "Congratulations! You have joined a new role". But they do not really belong to that role! It simply doesnt work. If I look into Users list, those new users are just Authenticated, but none get the new role "Authenticated +1". They are not really upgraded.
The email is sent on line 258 in userpoints_role.module:
userpoints_role_send_mail('join', $uid, $role_point);
But the next line apparently does not really work:
user_multiple_role_edit(array($uid), 'add_role', $rid);
This line is supposed to upgrade the role for real, but it doesn't.
Comments
Comment #1
Anonymous (not verified) commentedProblem is, in user.module on lines 350-358, the $roles is empty. Because userpoints (apparently) does not set the $roles again.
In the user.module code, then without $array['roles']containing the new data, the user roles are deleted again. Just after they were stored by user points, they are immediately deleted.
Have tried a lot to solve this, but I really can't find out why this happens. The new $roles is not passed on to user.module.
Comment #2
andrenoronha commentedI got this same issue on version 7 of the module. Have you got any solution?
Comment #3
qsurti commentedI believe the solution lies with the authors of the userpoint module. I have been searching around for past 10 days for a solution to upgrade a user based on userpoints earned but have failed in every attempt.
Comment #4
dRaz commentedThis module is vital to my website concept.
Please can somebody from the dev team comment as to when a new release will be issued?
The last comment by a maintainer on any issue was 15 weeks ago....I am not sure we will see a new release.....do we have anybody willing to take on the project if we receive no reply?
Comment #5
berdirThe 6.x-1.x branch of this project is more or less dead. (and 7.x-1.x is stalled too but much more stable.. the parts which are there, at least)
The modules in here are just a collection of modules that someone has developed at some point, it has been added and that's it.
If someone would be willing to take this over, it would have already happened I guess.
If you need this, your best change at this point is probably trying to pay someone to work on this, I simply don't have enough time at the moment.
Comment #6
dRaz commentedBerdir, thank you for the response.
Sorry to hear that you do not have the time as your knowledge of userpoints will be surely missed with any integrating modules going forward.
Unfortunately I do not have the coding knowledge to take this on, hopefully other members will.
Comment #7
qsurti commentedBerdir. Thanks for being honest and straight forward.
Who do you think will be willing to help and what do you think it would cost to get the update?
Comment #8
andrenoronha commentedHey guys, I came up with a solution using Rules.
1. Create a rule that will react on the event "User was awarded points"
2. Add the action "Load points of a user". Data selector for the user: "userpoints-transaction:user"
3. Add another action "Execute custom PHP code" and here is my code:
The $loaded_points variable comes from the other action I setup on step 2.
user_role_load_by_name and user_multiple_role_edit are new functions on Drupal 7.
If anyone knows a better and lighter way of doing that, feel free to change it.
Comment #9
qsurti commentedWill this code work on D7 version?
Comment #10
andrenoronha commentedIt's only for D7
Comment #11
qsurti commentedComment #12
dRaz commentedLuiz - Great work :)
Thank you so much for spending the time to post this. I am a believer in posting solutions too so kudos to you sir :)
I do have an issue though....
I have the following roles:
1 - anon
2 - auth
3 - admin
4 - user1
5 - user2
I have used the following code:
Now.....
- I was an auth user with 0 points.
- I created content until I hit 200 and voila! I was upgraded to user1 (although no message?????)
- I continued to create content until 800 and even 900 but it does not upgrade to user2.
Can you help me crack this please :)
Many thanks.
Shaun
Comment #13
andrenoronha commentedShaun,
try changing the line:
to:
I hope the bug was the '=' caracter. :)
But about the message not being shown, I really dont know what's happening... For me it works good.
Try any message without the variable just to check the function. Like: drupal_set_message('hello');
Comment #14
andrenoronha commentedHere is another exemple of the code I've been working with qsurti:
http://drupal.org/node/1293016#comment-5185762
Comment #15
dRaz commentedHu Luiz,
I had already changed that code - was a typo oops :)
Still not working though.....
I thought the issue could lie with this piece of code:
if ($loaded_points >800 && $level <= 2)
why do you include the "<" here?
Any further help? :)
Comment #16
andrenoronha commentedTry this now:
Comment #17
berdirNo idea why nobody ever looked at the source and tried to fix the actual error, the bug was rather trivial.
The bug is fixed in #443196: All roles are granted when a user earns points