I'm trying to set up a view permission based on a webform field. I've been able to get to my custom module using hook_webform_submission_access().

So I have an email field in the webform, and I want to check that based on the current user's email address. Should be pretty simple, I just can't get the field data. Anyone know?


if ($submission->data['field_email'] == $user->mail)

What is the correct syntax instead of $submission->data['field_email']

I'm on Drupal 7 and Webform 4.x branch.

1 Answer 1


Provided Token is installed, you can use token_replace to access Webform submission values by field name.

$email = token_replace('[submission:values:email]', array('webform-submission' => $submission));

Note: The Devel module can be useful for exploring object properties and tokens (among other things).

  • 1
    Thanks Labracadabrador. I do indeed have Token installed. I'll check this out at work tomorrow and let you know!
    – Dan
    Jan 15, 2018 at 22:11

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.