Skip to content

Commit

Permalink
chore: clarifying pattern usage
Browse files Browse the repository at this point in the history
  • Loading branch information
NiclasNorin committed Jun 25, 2024
1 parent 2b36d0d commit ae52e1e
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions source/php/Submission.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,17 +178,18 @@ public function submit()
$autoReplyFrom = $siteMailFromName . ' <no-reply@' . $siteMailFromDomain . '>';

// Send notifications
// Pattern for every field name is id-index-fieldName
if ($notify) {
foreach ($notify as $email) {
$sendMail = true;
if ($email['condition']) {
$pattern = '/^id-\d+-/';
$matchingValue = array_filter($_POST, function ($value, $key) use ($email, $pattern) {
$fieldNamePattern = '/^id-\d+-/';
$matchingValue = array_filter($_POST, function ($value, $key) use ($email, $fieldNamePattern) {
if ($value != $email['form_conditional_field_equals']) {
return false;
}

if (!preg_replace($pattern, '', $key) == sanitize_title($email['form_conditional_field'])) {
if (!preg_replace($fieldNamePattern, '', $key) == sanitize_title($email['form_conditional_field'])) {
return false;
}

Expand Down

0 comments on commit ae52e1e

Please sign in to comment.