Can I use a token within a custom token? I am trying to create a custom token that modifies another token.

$theDomainName = "[domain-name-raw]"; //Pull in the other token
$removeCounty = str_replace(" County", "", $theDomainName); //Replace " County" with nothing
$countyPlus = str_replace(" ", "+", $removeCounty); //Replace " " with "+"
return $countyPlus; //Return modified token as new custom token to be used through out site


If I use [domain-name-raw] for $theDomainName, my result is the original token (e.g. "Cerro Gordo County"). If I type what [domain-name-raw] should output for $theDomainName (e.g. "Cerro Gordo County"), my code works fine (it outputs "Cerro+Gordo"). What is going on?

I am using Drupal 6.
You could use something like token_replace() to get the other token value within your own token, but you shouldn't try to alter an already created token, as that will mess up when you really want to use that token.

You need to define you own token, and handle the output of that token. But in doing so, you will most likely find that it will be easier to get the raw values from the PHP values supplied instead of using token_replace() or something similar.

You need to look at hook_token_list() and hook_token_values() to define your custom token.