1

Send email to specific user :

For this i have added a webform contact to this person using webform.

after filling the information in webform by anonymous user , a mail should be sent to that user whose profile is he/she seeing.

Note: this functionality should only work for anonymous user and by using webform.

How to achieve this?

5
  • How on the webform does the anonymous user specify the user to be contacted? Is that a custom field on the webform? If not what do you have available to identify the person to be contacted? Commented Jun 23, 2016 at 8:03
  • i have placed the link on user profile ,ananomous user can see the profile of user ,uid is available
    – user52318
    Commented Jun 23, 2016 at 8:08
  • How does the path of that link look like? And how exactly is that "uid" available? Commented Jun 23, 2016 at 8:12
  • on clicking link webform opens on user profile of user
    – user52318
    Commented Jun 23, 2016 at 8:16
  • Your last comment is not an answer to my 2 questions in my last comment. Please retry to answer them. Commented Jun 23, 2016 at 8:18

1 Answer 1

2

Finally i found the solution by myself

1) Create a hidden field in webform say username field.

2)then go to /webform/emails .select the component value that is equal to username hidden field you previously created.then edit added component value in E-mail from address section select the component radio button instead of Default: [email protected] radio button.

3)then create a custom module add this code

 function your_module_form_alter(&$form, &$form_state, $form_id){

 if ($form_id == 'your_webform_id') {
    $uid = arg(1);
   if ( arg(0) == 'user' && is_numeric($uid) ) {
       $account = user_load($uid);
        $form['submitted']['Your-hidden-field-machine-name']['#value']   = $account->mail;
     }
   }

   }
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.