I have to redirect from a static URL to a specific page on the current user's account. I tried user/[site:current-user]/downloads but it doesn't work. Is there a way/setting/similar module where I can perform this redirect?

Comments

jaydub’s picture

I think the best way to accomplish this is to write a small custom module that handles the static path and redirects to the logged in users page or some other page if an anonymous user.

This is pseudocode but you'd want something like this:

foo.module

function foo_menu() {
  $items['path/to/your/static/url'] = array(
    'title' => 'static url redirect',
    'page callback' => 'foo_static_url_redirect',
    'access callback' => TRUE,
    'type' => MENU_CALLBACK,
  );

  return $items;
}

function foo_static_url_redirect() {
  global $user;

  if ($user->uid > 0) {
    drupal_goto('user/' . $user->uid . '/downloads');
  }
  else {
    drupal_access_denied();
  }
}
RKS’s picture

Ok. I'll check it out and see what I can come up with. Thanks for the tip.

davidwhthomas’s picture

I posted another solution, using hook_redirect_alter to apply user tokens, here: http://drupal.org/node/1331582#comment-6092790

pere orga’s picture

Issue summary: View changes
Status: Active » Closed (duplicate)

Let's close this as a duplicate of #1331582: Use tokens for redirects then