TransWikia.com

How to send email to submitter in a webform?

Drupal Answers Asked by cel57 on November 30, 2021

I have a webform and i want to send by mail this webform to submitter.
For the moment, i created an hidden field with token [current-user:mail] and i chose this field in adress.
I think it isn’t very well. Can I do it in hook_form_alter ? if yes, how to do it?

2 Answers

enter image description here

In Drupal 8 you can go to webform settings-> email/handler -> add email then select current user email address for To email.

Answered by shruti kadam on November 30, 2021

You can set a e-mail field in the webform, whether it is hidden or not is up to you. You should then set the current users e-mail address as the default value. For this, you will need hook_form_alter()

function YOURMODULE_form_alter(&$form, $form_state, $form_id) {
  //drupal_set_message($form_id); (uncomment this to get form id)
  if ($form_id == 'your_webform_id') { 
    global user;
    if ( $user->uid ) { //check user is logged in
    $form['field_email']['und'][0]['value']['#default_value'] = $user->mail;
    }
  }
}

Answered by Collins on November 30, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP