Form From Email

Permalink
I'm using the default Form block for a simple contact form. But, instead of the email always coming from the same (admin) email, I would like to have it dynamically pull the email provided by the user filling in the contact form. Would this be very hard?

 
ConcreteOwl replied on at Permalink Best Answer Reply
ConcreteOwl
Easy enough
Just copy the forms folder from the root/concrete/blocks/ folder and paste it into the root/blocks/ folder,
Open the controller.php file and around line 392 find this
}else{ 
               $adminUserInfo=UserInfo::getByID(USER_SUPER_ID);
               $formFormEmailAddress = $adminUserInfo->getUserEmail();
                           }

Replace it with this
}else{ 
               $adminUserInfo=UserInfo::getByID(USER_SUPER_ID);
               /*$formFormEmailAddress = $adminUserInfo->getUserEmail();*/
               $formFormEmailAddress=$questionAnswerPairs[2]['answer']; 
            }

But be aware that the question in your form that asks for the users email address must correspond to the $questionAnswerPairs[#] and in the example above the question was number 2 on the form..
newfive replied on at Permalink Reply
Aha! Sweet, thank you! Now, I guess I'm in trouble if someone were to ever re-order and/or add new questions, correct? What I was trying to do earlier was mess with this part:

}elseif($row['inputType']=='email'){
   $answerLong="";
   $answer=$txt->sanitize($_POST['Question'.$row['msqID']]);


But wasn't having any success. This should work fine for now. Just curious how I could future proof it. I know that will take more work though :)

Thanks again, it worked!
ConcreteOwl replied on at Permalink Reply
ConcreteOwl
Just make sure that your question 2 on all your forms require the users email address as an answer..