Skip to content

Commit 719219b

Browse files
authored
Merge pull request #100 from SparkPost/template-attachment-doc
add templates/attachment related comments/docs
2 parents 2209375 + 7453e13 commit 719219b

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

admin.widget.class.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,9 +245,10 @@ public function render_template_field()
245245
value="<?php echo $this->settings['template']; ?>"/><br/>
246246
<small>
247247
<ul>
248-
<li>- Please see <a href="https://support.sparkpost.com/customer/portal/articles/2409547-using-templates-with-the-sparkpost-wordpress-plugin">this article</a> for detailed information about using templates with this plugin.</li>
248+
<li>- Please see <a href="https://support.sparkpost.com/customer/portal/articles/2409547-using-templates-with-the-sparkpost-wordpress-plugin" target="_blank">this article</a> for detailed information about using templates with this plugin.</li>
249249
<li>- Templates can only be used with the HTTP API.</li>
250-
<li>- Leave this field blank to disable use of a template.</li>
250+
<li>- <a href="https://github.com/SparkPost/wordpress-sparkpost/blob/master/docs/templates-attachments.md" target="_blank">Does not work with attachment</a>.
251+
<li>- Leave this field blank to disable use of a template or use it dynamically (i.e. <a href="https://github.com/SparkPost/wordpress-sparkpost/blob/master/docs/hooks.md" target="_blank">using hooks</a>).</li>
251252
</ul>
252253
</small>
253254
<?php

docs/templates-attachments.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Sending Attachments with Template
2+
3+
Currently, you [can't send attachments](https://support.sparkpost.com/customer/portal/articles/2458261-can-attachments-be-sent-when-using-templates-) if you are you using a template. There are [technical work arounds](https://www.sparkpost.com/blog/advanced-email-templates/) but this is not still supported by SparkPost plugin yet.
4+
5+
## Interim solution
6+
If all of your emails has attachments, easiest solution is not to use any template at all (i.e. Keep `Template` field empty).
7+
8+
However, if some of your emails use template (and they do not have attachments), you can specify a template ID in settings and then use the hook to remove the template just before creating that email that has attachment(s).
9+
10+
Here is an example:
11+
12+
```
13+
function remove_template() {
14+
return false;
15+
}
16+
17+
//register the filter
18+
add_filter('wpsp_template_id', remove_template);
19+
20+
// call wp_mail with attachments
21+
remove_filter('wpsp_template_id', remove_template); //so other emails use template as usual.
22+
```
23+
24+
## Change in future
25+
In future SparkPost may support sending attachments with Templates. Also, we can consider the implementing the alternative that is mentioned above directly inside this plugin.
26+
27+
Track [this issue](https://github.com/SparkPost/wordpress-sparkpost/issues/97) to know the latest regarding this.

0 commit comments

Comments
 (0)