This should be easy to do, but its very hard to Google.

Within the admin and surrounding workflows, various links point to user/foobar. I have a different page to display users, say /faces/xx. I want to intercept (or rewrite) every url linking to user/foobar/ to faces/xx.

Pathauto lets you customize what paths user profiles have. If I set that to /faces/[user:uid], it will create aliases overriding my module router; so that faces/xx looks the same as user/foobar previously did. That is not what I want.

You can redirect users on login or other triggers. That is also not what I am looking for.

Most likely, I can override something in my module that intercepts user/foobar calls and does a drupal_goto('faces/xx'). Or there is a url_alter that I can override that writes out the user/foobar links. That, or something similar, is what Im looking for.

EDIT -- sample code from the module that generates the faces page

function faces_menu() {
    $items = array();
    $items['faces/%'] = array(
        'title'             => t('Face'),
        'access callback'   => true, // more complex in reality
        'page callback'     => 'faces_page',
        'page arguments'    => array(1,2),
        'type'              => MENU_CALLBACK,
    return $items;
function faces_page($uid) {
    global $user;
    $output =  array(
        'faces-page' => array(
            'magic'     => voodoo($uid),
            '#theme'    => 'faces_pages'
    return $output;

and ofcourse theres a faces_theme() to match it.

  • Why is aliasing not acceptable?
    – Geoff
    Jun 2, 2015 at 11:52
  • Sounds like you're looking for hook_url_inbound_alter()
    – Clive
    Jun 2, 2015 at 11:55
  • @Geoff aliasing would be acceptable, as long as the end point of the link is my module page (pathauto doesnt do that)
    – commonpike
    Jun 2, 2015 at 13:44
  • @Clive, yes url_inbound_alter might help. i've updated the question a bit to illustrate why i cant easily use it: drupal links to user/[username] and I want to link to faces/[uid]; so I would have to resolve [username], probably with urlencoding, to [uid]
    – commonpike
    Jun 2, 2015 at 13:47
  • 1
    yup... well, you can do a redirect in hook_boot() or a number of other hooks, but depending on what voodoo() returns, I might first try implementing this in hook_user_view() or hook_user_view_alter() with the existing pathauto alias
    – Geoff
    Jun 3, 2015 at 15:28

1 Answer 1


d'oh! thanks to @geoff above .. this seems to work (in a module called 'faces')

function faces_user_view($account, $view_mode, $langcode) {
    if ($view_mode=='full') {
  • I actually meant to include the results of voodoo() here to build the user profile, not the redirect, but hey, if it works :)
    – Geoff
    Jun 4, 2015 at 2:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.