function url_alter_test_url_outbound_alter

Implements hook_url_outbound_alter().

File

modules/simpletest/tests/url_alter_test.module, line 58

Code

function url_alter_test_url_outbound_alter(&$path, &$options, $original_path) {
    // Rewrite user/uid to user/username.
    if (preg_match('!^user/([0-9]+)(/.*)?!', (string) $path, $matches)) {
        if ($account = user_load($matches[1])) {
            $matches += array(
                2 => '',
            );
            $path = 'user/' . $account->name . $matches[2];
        }
    }
    // Rewrite forum/ to community/.
    if ($path == 'forum' || strpos((string) $path, 'forum/') === 0) {
        $path = 'community' . substr($path, 5);
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.