Basic premise: Mailer that allows end-user to type their name, their email and send an evite (just an image) of their choice to an email recipient. Recipient receives the email template which includes the image and a greeting message.
I have the email function built and it works, it’s just a matter of figuring out how to print the data that is spit out from a custom field that sits inside of the wordpress loop.
This is the body of the email I’ve mocked up so far for testing purposes:
$body = "
<html>
<head>
<title>new evite!</title>
</head>
<body>
<p>Here is your new evite</p>
<table>
<tr>
<td><img src='".$thePostID."' alt='' /></td>
</tr>
<tr>
<td>Name: $name<br />Email: $email<br />Comments: $comments</td>
</tr>
</table>
</body>
"
$thePostID defined:
$thePostID = the_field('evite_large_preview');
the_field function is from a popular wordpress plugin, Advanced Custom Fields.
the_field(‘evite_large_preview’); will just echo out the URL of the image from a post.
No value is being echoed out for $thePostID so no image shows up when recipient checks their email.
Why might this be happening? The function works on the site just fine, but doesnt show up in the email body.
EDIT: I figured it out:
Used get_field instead of the_field for storing ‘field’ as variable. Placed variable inside of its own wordpress loop solved it.