How to access values from earlier steps in multi-page Webform? I'm using Webform 4. It uses Drupal's tokens, not it's own % tokens like it used to in version 3, and pretty much all what I found was about webform 3.

Say I want to make multi-page subscription form. On first page there is only an email field. On second one, I want a markup that will say something like:


  Detailed subscription configuration for molot@example.com


Similarly, I'd like to be able to use them as default values for future fields, like asking user for billing address, and then for delivery address.

Are there any tokens for that? What I did for now is:

function mymodule_token_info() {
  $type = array(
    'name' =&gt; t('Webform submitted values'),
    'description' =&gt; t('Tokens related to $_POST[\'submitted\'].'),
  );
  $tokens = array();
  if(isset($_POST['submitted'])) {
    foreach($_POST['submitted'] as $key =&gt; $val) { //discard $val now
      $tokens[$key] = array(
        'name' =&gt; $key,
        'description' =&gt; "\$_POST['submitted']['$key']",
      );
    }
  }
  return array(
    'types' =&gt; array('webform_submitted' =&gt; $type),
    'tokens' =&gt; array('webform_submitted' =&gt; $tokens),
  );
}

function mymodule_tokens($type, $tokens, $data, $options) {
  if($type == 'webform_submitted') {
    $replacements = array();
    foreach ($tokens as $name =&gt; $original) {
      //Hide errors below. We don't care if it really exists yet. If empty, so be it.
      @$replacements[$original] = (string)$_POST['submitted'][$name];
    }
    return $replacements;
  }
}


It works, but it only shows values from one step earlier, so requires some dirty tricks with hidden fields to carry email value across multiple steps. I admit - it was just quick and dirty. Is there any built-in way to do it, or properly maintained contributed module for this? Or a way to make this code work independently of $_POST['submitted'], to make it carry values across many steps and to make it's tokens (from available Webform elements) visible on token list in edit windows?
This does not answer the question in your title, but reading your use case it sounds like the scenario that Profile2 was written for.  Related stackoverflow post

Webform is great for surveys and such, but when you want "to be able to use them as default values for future fields" they need to be connected to the user.  So you would then need more custom code to fetch the user's historic webform submission to pull these values in a form alter for your billing address.  Profile(2) is written precisely to make this easier.

Also, the less last-minute custom coding you are doing before handing this off to some one else, the less that some one else will curse you in their heart when they are trying to make updates.