Brian Coolidge
Brian Coolidge

Reputation: 4649

Redirect user using rules after competing registration in drupal 7

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

enter image description here

Now here's the problem goes,

I've created a rule which is after the user successfully registered.

enter image description here

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

https://drupal.stackexchange.com/questions/50300/how-to-redirect-anonymous-users-to-login-page-using-rules-module

Upvotes: 3

Views: 1660

Answers (0)

Related Questions