Skip to content

Commit b2fab1d

Browse files
committed
add docs
1 parent 14fcc69 commit b2fab1d

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

docs/transactional.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
2+
# Transactional setting
3+
4+
## Background
5+
As of v2.5.0 (TODO: Fix version number before release), wordpress-sparkpost introduced [Transactional](https://www.sparkpost.com/blog/transactional-email-vs-mass-email) support for emails.
6+
7+
Emails created by WordPress are, generally, transactional in nature. Those are user registration, password reset emails etc. So, we wanted to set that flag on by default. Non-transactional emails are generated by third party plugins. In such case, that plugin should mark it as non-transactional. Because this option supports hook, it's easy to programmatically flip the value. We'll have an example below.
8+
9+
Also because this is quite a breaking change, we won't just change this value for the existing installations. Any current installations of this plugin upgraded to new version will have this unchecked by default.
10+
11+
## New Installations
12+
For new installations, Transactional will be enabled by default. In plugin's settings page, it'll be checked on. If you want to disable it, just uncheck and save the settings.
13+
14+
## Upgrades
15+
If you are upgrading to this new version from an existing installation, it won't be enabled by default. You must go to plugin's setting page and enable it from there.
16+
17+
## Programmatically modifying transactional setting
18+
If you know that you're sending a non-transactional email, you can set it to false before sending using a filter and then remove the filter after you sent the email. Here is an example:
19+
20+
```php
21+
function unsetTransactional() {
22+
return false;
23+
};
24+
25+
add_filter('wpsp_transactional', 'unsetTransactional');
26+
27+
// now send your email using wp_mail function
28+
29+
// as sending is done, let's remove the filter so other emails are not affected
30+
remove_filter('wpsp_transactional', 'unsetTransactional');
31+
```

0 commit comments

Comments
 (0)