Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
33 lines (21 sloc) 1.71 KB

Transactional setting


As of v2.5.0, wordpress-sparkpost introduced Transactional support for emails.

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.

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.

New Installations

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.


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.

Programmatically modifying transactional setting

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:

function unsetTransactional() {
  return false;

add_filter('wpsp_transactional', 'unsetTransactional');

// now send your email using wp_mail function

// as sending is done, let's remove the filter so other emails are not affected
remove_filter('wpsp_transactional', 'unsetTransactional');
You can’t perform that action at this time.