Hello,
I have created a rule: when an anonymous user leaves a comment, it:
- creates a new user with name and email address from poster of the comment
- unblock this user account (dunno why it is blocked by default)
- sends an email with the login one time link for the user to activate the account.
Eveything works fine (user created, unblocked, email sent with link), but the page opened by the link is always "access denied".
I have tried deleting the cookies, cache, etc. + tried changing the combination on "/admin/config/people/accounts" for users registration rights.
=> but I still have an "access denied" page all the time.
However, when I send the login one time link simply by clicking on the button from the user page, the link works ok.
What am I missing here ? Is it something related to the user role ?
Comments
Comment #1
danielb CreditAttribution: danielb commentedCan you compare the links being sent (good link and bad link) in the emails and/or show me what they are?
Are you configuring a custom path to send them to, etc.. ?
Comment #2
Louis Bob CreditAttribution: Louis Bob commentedThanks for your prompt reply.
Link sent via Rules:
http://www.mydomain.com/login_one_time//1334048890/Yeec0-Y5Vcpq_7II-pJRX...
Link sent via the Login One Time button:
http://www.mydomain.com/login_one_time/97/1334049016/ZQNxQ7RKBuvYV4VfTdS...
vA?destination=user/97
So it seems that the user ID (97 here) is missing in the Rules link, that should instead read:
http://www.mydomain.com/login_one_time/97/1334048890/Yeec0-Y5Vcpq_7II-pJRXSjprWkbZrlbrlvbtVUWv6Y?destination=comment/reply/2
Also I have these error messages when the rule is applied, which would explain why the user ID is missing. However, the user is correctly created before the email is sent, so I don't understand the problem.
Anyway I have manually added the user ID to the Rules link, and no more "access denied", but this message instead:
I am a bit confused here...
Comment #3
danielb CreditAttribution: danielb commentedAt this point I'm confused because I don't remember such functionality (sending the email link through Rules) being provided by this module, and I don't see how that is allowed for in the code.
I am not a user of the Rules module so there might be some information I don't have about where it gets it's data/integration from.
Comment #4
Louis Bob CreditAttribution: Louis Bob commentedWell a variable from your module is available in Rules, therefore it can be sent via email.
Thanks for your responses, I have opened a support request in the Rules issues, since it seems more directly related:
http://drupal.org/node/1528492
Comment #5
rachelf CreditAttribution: rachelf commentedHi there
I have had a similar problem, and it is rules related. The user id is missing because the new user entity that rules has created is not saved until the end of the rules evaluation.
I have successfully used this by first saving the user that I have just created (until this point the user id is unassigned).
My sequence of actions goes:
Create a new entity (the new user)
Save entity (force saving immediately)
Add user role
Unblock user
Execute custom PHP code:
Hope this helps!
Comment #6
Louis Bob CreditAttribution: Louis Bob commentedHello Rachelf,
You're a life savior: it works perfectly :)
Thanks a lot!
Comment #7
Rosamunda CreditAttribution: Rosamunda commentedThanks rachelf! Your insight solved my problem too!
BIG THANKS!