Form Block "From E-Mail" Address Fix Help

Permalink
The Form Block does not submit notifications from the correct address and defaults to the Super User e-mail of the site. The function that finds a valid e-mail from the form does not work.

Here is the section of controller.php in question:

if(
strlen(FORM_BLOCK_SENDER_EMAIL)>1 && strstr(FORM_BLOCK_SENDER_EMAIL,'@')
)
{
$formFormEmailAddress = FORM_BLOCK_SENDER_EMAIL;
}
else
{
$adminUserInfo=UserInfo::getByID(USER_SUPER_ID);
$formFormEmailAddress = $adminUserInfo->getUserEmail(); 
}


I have replaced it with this:

$formFormEmailAddress = $_POST["Question2"];


This works great as long as the e-mail address is always Question2.

Any help on fixing the string search so it finds the e-mail address from the form?

 
vGibson replied on at Permalink Reply
vGibson
Something I did as a quick solution was use your idea of using the post data for question 2 but I used a if/else to keep the original functions intact in case someone does not enter an email or if you have another form that does not have an email field.

I replaced the original

if(
strlen(FORM_BLOCK_SENDER_EMAIL)>1 && strstr(FORM_BLOCK_SENDER_EMAIL,'@')
)
{
$formFormEmailAddress = FORM_BLOCK_SENDER_EMAIL;
}
else
{
$adminUserInfo=UserInfo::getByID(USER_SUPER_ID);
$formFormEmailAddress = $adminUserInfo->getUserEmail();
}


with the following

if (strstr($_POST["Question2"], '@')) {
      $formFormEmailAddress = $_POST["Question2"];
  } else {
    if( strlen(FORM_BLOCK_SENDER_EMAIL)>1 && strstr(FORM_BLOCK_SENDER_EMAIL,'@') ){
      $formFormEmailAddress = FORM_BLOCK_SENDER_EMAIL;
    }else{
      $adminUserInfo=UserInfo::getByID(USER_SUPER_ID);
      $formFormEmailAddress = $adminUserInfo->getUserEmail();
    }
  }