Custom Field in a email message body
-
Hi: I’m trying to print a Custom Field in a email message body.
I have tried with:
'. get_field('client_name', $post_id).'
'. the_field('client_name', $post_id).'
'.do_shortcode( get_field('client_name') ).'
'.do_shortcode( the_field('client_name', $post_id) ).'
'.do_shortcode( get_field('client_name', $post_id) ).'
and…
'.do_shortcode( the_field('client_name') ).'
Without results.This is an example of my code in functions.php
// Sent email on every post function rhk_send_email($id) { $post = get_post($id); $headers []= "MIME-Version: 1.0\r\n"; $headers []= "Content-Type: text/html; charset=UTF-8\r\n"; $headers []= "From: My website <my@email.com>"; $headers []= "Reply-To: my@email.com" ; $to = "my@email.com"; $subject = "News of my web"; $message = Dear '. get_field('client_name', $post_id).' This is your message. wp_mail($to, $subject, $message, $headers); } add_action('publish_post', 'rhk_send_email');
Any help will be welcome!
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Custom Field in a email message body’ is closed to new replies.