Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add action hook so we can save the messageid after the email is sent #23

Merged
merged 2 commits into from
May 9, 2017

Conversation

aytackokus
Copy link

@aytackokus aytackokus commented Mar 24, 2017

This is an enhancement for the issue #22

This feature will allow us to save MessageID after the email is sent.

If you want to save the MessageID to a POST, then you need to add the post id to the $headers argument of wp_mail function. This will not create any malfunctions with email part, because the headers does get filtered to a new variable ($recognized_headers).

For example:
$headers['post_id'] = $post_id;

Arguments sent with the hook:
$response = response from postmarkapp API
$headers = headers from wp_mail function

So after the email is sent, we can catch the response_data by adding an action hook.
add_action('postmark_response', 'handle_postmark_response', 10, 2);

function handle_postmark_response($response_data, $headers) {
$response_data = json_decode($response_data['body']);
$post_id = $headers['post_id'];
$message_id = $response_data->MessageID;
}

@atheken
Copy link
Contributor

atheken commented Mar 24, 2017

@aytackokus - This is really great. Since I'm not a wordpress guru, I've struggled with how best to provide this feedback, without breaking the wp_mail convention. This is a really elegant solution to that problem. I think it could also make sense to emit a hook for sending errors. What do you think?

@aytackokus
Copy link
Author

aytackokus commented Mar 24, 2017

@atheken Thanks. I think adding a hook for sending errors is a nice to have feature.

@aytackokus
Copy link
Author

@atheken do you want me to add it? or will you do it?

@atheken
Copy link
Contributor

atheken commented Mar 28, 2017

@aytackokus If you have time to take a crack at it, I would appreciate it.

@aytackokus
Copy link
Author

@atheken it is done!

@aytackokus
Copy link
Author

Hello @atheken, when will you push this changes to the plugin?

@atheken atheken merged commit 7fea311 into ActiveCampaign:master May 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants