Programmatically redirect I'm creating an action to trigger on a rule when a user is logged in. I have a field of the user that is a term reference.

I would like to redirect to the url field of the chosen term. This is how I get the chosen url:

$tid = $user-&gt;field_redirect_field['und'][0]['tid'];
$taxonomy = taxonomy_term_load($tid);
$url = $taxonomy-&gt;field_url['und'][0]['safe_value'];


I receive a perfect url like stocklijst/gezocht (this works ok). Now I would like to redirect to that url. I've tried this:

drupal_goto($url);


But it doesn't redirect. It always goes to the front-page...

UPDATE:

This is what I do now:

I have a rule (When user logged in) that triggers a custom action "Redirect to user url". It's a custom action like this:

function redirectonlogin_rules_action_info() {
    $actions = array(
        'redirectonlogin_redirect_login' =&gt; array(
            'label' =&gt; t('Redirect on login'),
            'group' =&gt; t('My custom actions'),
            'parameter' =&gt; array(
                // curent user
                'user' =&gt; array(
                    'type' =&gt; 'user',
                    'label' =&gt; t('User'),
                    'description' =&gt; t('The current logged in user.'),
                    'save' =&gt; FALSE,
                ),
            ),
        ),
    );
    return $actions;
}

function redirectonlogin_redirect_login($user) {
    // REDIRECT TO USER REDIRECT FIELD
    $tid = $user-&gt;field_redirect_field['und'][0]['tid'];
    $taxonomy = taxonomy_term_load($tid);
    $url = $taxonomy-&gt;field_url['und'][0]['safe_value'];

    unset($_GET['destination']);
    drupal_static_reset('drupal_get_destination');
    drupal_goto($url);
}


The user can select a url in a select list. These are taxonomy terms... .

This works perfectly. But it takes some time, could there be a cleaner way and faster way of doing this?
You could use hook_form_alter(),
In this hook we could redirect with $form['redirect'] = $url;