Home › Forums › Add-ons › Repeater Field › Get $_POST['acf'] value of repeater field in post object › Reply To: Get $_POST['acf'] value of repeater field in post object
Just to be clear…
I know how to get all these values within a template file, simply because there I can use it like this:
$measurement_client_object = get_field_object('measurement_client');
$measurement_client = get_field('measurement_client');
$measurement_client_name = get_the_title($measurement_client->ID);
$measurement_client_street_and_number = get_field('company_street_and_number', $measurement_client->ID);
$measurement_client_postal_code = get_field('company_postal_code', $measurement_client->ID);
$measurement_client_city = get_field('company_city', $measurement_client->ID);
$measurement_client_phone_number = get_field('company_phone_number', $measurement_client->ID);
$measurement_client_website = get_field('company_website', $measurement_client->ID);
$measurement_client_email_addresses = get_field('company_email_addresses', $measurement_client->ID);
$measurement_client_contacts = get_field('company_contacts', $measurement_client->ID);
$measurement_client_locations = get_field('company_locations', $measurement_client->ID);
$measurement_client_internal_note = get_field('company_internal_note', $measurement_client->ID);
But within my function.php I can’t get the values like that and I believe I have to use $_POST[‘acf’].
I call the code to send out WP emails.
Here’s my code (option ‘basic’ is not working yet, option ‘extra’ does work, option ‘all’ is easily created when I have option ‘basic’ working):
// Get submitted values.
$values = $_POST['acf'];
$measurement_status = $_POST['acf']['field_5e1475a714c93'];
$measurement_mail = $_POST['acf']['field_5f71d9ee8536c'];
if ( $measurement_status == 'completed' && $measurement_mail ) {
$measurement_mail_report_recipients = $_POST['acf']['field_5f6d7d925b2fc'];
if ( $measurement_mail_report_recipients == 'basic' ) {
$measurement_client_id = intval($_POST['acf']['field_5e147914518a6']);
$measurement_client = $_POST['acf']['field_5e147914518a6'];
$measurement_client_email_addresses = $_POST['acf']['field_5e14527c1945b']->$measurement_client->$measurement_client_id;
if ( $measurement_client_email_addresses ) {
$list = array();
foreach( $measurement_client_email_addresses as $measurement_client_email_address ) {
$list[] = $measurement_client_email_address['field_5e1452c41945c'];
}
$to = implode(',', $list);
}
} elseif ( $measurement_mail_report_recipients == 'extra' ) {
$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'];
}
$to = implode(',', $list);
}
} elseif ( $measurement_mail_report_recipients == 'all' ) {
$to = '[email protected]';
}
// Get subject, message and header for mail and send
}
Within option ‘basic’ I want to retrieve email addresses from the CLIENT group and I don’t know how because these values are within another group 🙁
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
📣 “ACF Chat Fridays”
— Advanced Custom Fields (@wp_acf) January 31, 2023
The ACF team holds their first open office hours this Friday! Come and talk ACF, and ask questions about building sites with the plugin.
We’d love to see you there!
📆 Friday 3rd Feb - 3pm UTC
👉 Register here - https://t.co/3UtvQbE4CU pic.twitter.com/oTwW9K1XQ0
© 2023 Advanced Custom Fields.
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.