Home › Forums › Backend Issues (wp-admin) › Use posted acf value in other acf field (same post)
I have a custom post type: bookings
The process goes like this:
1 Guest makes booking via frontend form
2 Pending booking post was created with the booking fields inside
3 Admin changes field BOOKING STATUS from pending to confirmed
4 Guest auto receives BOOKING CONFIRMED email
So far so good and everything works great!
But here is comes…
To be more flexible I also create an email subject field and an email message field and I would like to use the submitted values inside so I can personalize the email.
Within the email instead of: Hi Guest, your booking was confirmed.
I want to be able to use: Hi Dennis, your booking this Friday at 20.00 hours was confirmed.
I figured out that the following does not work:
Hi [acf field="name"],
(they do work in the original post content field but can’t use that field to output because I have flexible email message fields related to the booking status)
The shortcake example that does not work. Within the email it outputs this [acf field=\"bookings_field_last_name\"]
Emails from WP do not run shortcodes by default, you need to make that happen. There are some plugins that will do this or you can add code to your site.
add_filter('wp_mail', 'shortcodes_in_wp_mail', 20, 1);
function shortcodes_in_wp_mail($args) {
$args['message'] = do_shortcode($args['message']);
return $args;
}
Now I don’t see anything so the code is gone but the output becomes blank.
Just to mention again: The shortcodes are added to an ACF textarea field and that field is used as email BODY. So I do not use the regular content field from the post itself.
Any other ideas? I saw your example code online asiel and many people say it works so I guess it does but only for the regular content field and not for ACF fields?
I also tried to activate shortcode within ACF field by adding this to functions.php but again the same blank result:
add_filter('acf/format_value/type=textarea', 'do_shortcode');
add_filter('acf/format_value/type=text', 'do_shortcode');
Anything?
The topic ‘Use posted acf value in other acf field (same post)’ is closed to new replies.
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!
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 Privacy Policy. If you continue to use this site, you consent to our use of cookies.