Output comma separated list of ACF repeater sub field values

401 views Asked by At

I have an ACF repeater field field_5f71d4eaaf381 for email addresses and I want to output a comma separate list of the sub field values (measurement_extra_email_address) to create a $to for the WordPress mail function.

            $values           = $_POST['acf'];
            $extra_recipients = $_POST['acf']['field_5f71d4eaaf381'];

            if ( $extra_recipients ) {
                $list = array();
                foreach( $extra_recipients as $extra_recipient ) {
                    $list[] = $extra_recipient['measurement_extra_email_address'];
                }
                $to = implode(',', $list);
            }

I thought above code should/would do it but no email is being send so I guess the code is incorrect..?

Just a note: When I remove above part of the code and just try $to = '[email protected]'; an e-mail is being send so the error should be in there...

1

There are 1 answers

0
Yorlinq On BEST ANSWER

Here's the code I was looking for:

            $values = $_POST['acf'];
            $measurement_mail_extra_recipients = $_POST['acf']['field_5f71d4eaaf381'];

            if ( $measurement_mail_extra_recipients ) {
                $list = array();
                foreach( $measurement_mail_extra_recipients as $measurement_mail_extra_recipient ) {
                    $list[] = $measurement_mail_extra_recipient['field_5f71d55aaf382', $measurement_client];
                }
                $to = implode(',', $list);
            }