Hi Folks,

I am using the "Auto Assign Role" module to assign my new users to a role called "Spa Customer"

Then I set up a Rule that says "ON event User account has been created" and the condition is user type "Spa Customer"

Redirect to a specific URL.

This does not work, they get directed to the home page every time. Can someone please help? I am pulling my hair out, this is not supposed to be so hard!?

If I change the condition to "when a spa customer logs in" redirect to a URL, that works, but I only want to send them to this URL after creating the account.

Please help and thank you.

Comments

WorldFallz’s picture

I don't think you can do it this way. Try using the' user logs in' event but add a condition to check that last access is 'never' (in other words, it's their first login).

jburnard’s picture

One more question for you I'm having trouble being able to define "last access is never" I'm assuming my event is "user logged in" then my condition is where I'm having trouble... Should it be "check a truth value"? Plus I'm not finding a token for last access. Sorry to be so dense. Any help is appreciated.

WorldFallz’s picture

hmm... the php check would be $user->access == '0', not sure about the tokens. I seem to remember something about [user:log-date] or [account:log-date]-- is there anything like that available?

jburnard’s picture

Hi, Yes there is a [account:log-date], but just not sure how to write that statement.

jburnard’s picture

Also, I'm sure there's no reason I need to use the token approach. If I could make your php version work it would do the same thing right? I tried adding $user->access == '0' into my condition of "check a truth value" but still no luck. I'm probably missing something very simple as it seems redirecting a user when they log in the first time should be easy. Any thoughts? Thanks again.

WorldFallz’s picture

Try putting something like this in the php eval textbox (of the 'test truth value' condition):

<?php $user->access ? true : false; ?>

EDIT: in case it's not obvious, be sure to include the '<?php' and '?>' tags.

jburnard’s picture

I really appreciate your patience with me... I tried that but no luck. I wonder if I'm putting that code in the right place. After my event, I add a condition and I'm using "Check a truth value" then in the truth value field I added your code. Is that right?

After rereading your last post I'm pretty sure I'm doing just what you said. If it helps here is a screenshot:

http://www.cypressbeauty.com/temp/image.jpg

WorldFallz’s picture

No problem. Happy to help.

However, I've been poking around the rules issue queue, and it seems there might be a problem doing this with rules. See #517396: 'Has role' condition unavailable at account creation and #328384: Assigning roles to newly created users. It might be worth posting over there.

The only other thing I can think of is implementing http://api.drupal.org/api/function/hook_user in a little custom module. :-(

EDIT: maybe http://drupal.org/project/login_destination ?

jburnard’s picture

Ok, at least it's not me just missing something. Thanks again for all your help, I'll check out those links.

WorldFallz’s picture

Nope-- something definitely changed, since d5 I think. Also, another option worth checking might be http://drupal.org/project/logintoboggan.

Canine Coaches’s picture

My guess is rules is "running" before auto_assign_role and therefore thee users are not "spa customers" yet. Have you tried removing the user type condition from the rule? If users are auto assigned a role when creating an account then couldn't you just redirect all users who created an account to a specific url?

jburnard’s picture

Thanks so much guys for the suggestions. I will check them both out. Canine Coaches, my only problem with your suggestion is that I have more than one customer type, so if they aren't "spa customers" then I don't want them to be directed to that url. I should have explained that.

Thanks again.