Reputation: 4649
A little bit of background of what I've been doing before I go straight to my question.
I used Toboggan Drupal Module and let the user automatically log in after complete registration
At the registration page, there's a Price Plan that the user has to chose from.
$4.95:
ID: p_1
Redirects to page(page name): 001
$14.95:
ID: p_2
Redirects to page(page name): 002
$29.95:
ID: p_3
Redirects to page(page name): 003
After completing all the registration fields including the price plan. It will be redirected to a corresponding page listed above instead of being redirected to mysite.com/user
Now here's the problem goes,
I've created a rule which is after the user successfully registered.
The action is execute custom php code
<?php
global $user;
$uid = $user->uid;
$result = db_query("SELECT field_price_plan_value FROM field_data_field_price_plan WHERE entity_id = :uid",
array(
':uid' => $uid
))->fetchField();
if ($result == "p_1") {
header("Location: 001");
} else if ($result == "p_2") {
header("Location: 002");
} else if ($result == "p_3") {
header("Location: 003");
}
After the user registered, the user didn't redirect to a certain page. For example, I've picked $14.95 after my successful register, I should be redirected to mysite.com/002 but instead I just redirected to default mysite.com/user.
Any possible solution for this? A help would be nice.
I even used drupal_goto() instead of header(), still didn't worked though.
Edit
Here's some kind of duplicate questions, but yet, I still didn't manage to apply well on my problem.
How to redirect user to a specific page after they login if they belong to a certain role?
Drupal 7 system redirect through rules module
Upvotes: 3
Views: 1660