New answers tagged

1

Thanks @leymanx for the suggestion to make my own custom token. That's what I did. I created a hook_tokens function that borrowed code from webform.tokens.inc hook_tokens implementation. I deleted anything that didn't relate to the one token I was after, then created a _module_name_token_get_submission_values function that also borrowed heavily from the ...


2

The current-user token will always take its data from the current user, you can't override it with parameters. See user_tokens: if ($type == 'current-user') { $account = User::load(\Drupal::currentUser() ->id()); $bubbleable_metadata ->addCacheContexts([ 'user', ]); $replacements += $token_service ->generate('user', $tokens, ...


0

Your approach $user = User::load($uid); $message_value = $token->replace($message,['user' => $user]); doesn't work because of user.tokens.inc:153 (as of 8.8.11): if ($type == 'current-user') { $account = User::load(\Drupal::currentUser()->id()); $bubbleable_metadata->addCacheContexts(['user']); $replacements += $token_service->...


2

One approach to this issue is to interpret tokens on your own via hook_tokens(). hook_tokens() is called every time a token is interpreted and gives you an opportunity to determine how that token is interpreted. Even though the token [webform_submission:node:field_gated_download:entity:field_media_file:entity:url] is already defined, it may be necessary to ...


0

Through some trial and error and some further digging, I figured it out. Here's what works: URL: [entityform:field-file-upload:0:file:url] Filename: [entityform:field-file-upload:0:file:name] Upload date: [entityform:field-file-upload:0:file:timestamp:short] Increment the 0 to return more files from the multi-value array of uploaded files. Once I had the ...


Top 50 recent answers are included