Skip to content

Instantly share code, notes, and snippets.

@ipokkel
Created December 10, 2024 06:32
Show Gist options
  • Save ipokkel/faa175534061951bd680793d149ffa8c to your computer and use it in GitHub Desktop.
Save ipokkel/faa175534061951bd680793d149ffa8c to your computer and use it in GitHub Desktop.
<?php
/**
* Add a reply-to address to PMPro email headers.
*
* You can add this recipe to your site by creating a custom plugin
* or using the Code Snippets plugin available for free in the WordPress repository.
* Read this companion article for step-by-step directions on either method.
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function add_reply_to_pmpro_email_headers( $headers, $email ) {
// Set the reply-to address.
$reply_to_name = 'John Doe'; // set to '' to use blog name
$reply_to_email = '[email protected]'; // set to '' to use blog email
// If no name or email is set, use the blog name and email.
if ( empty( $reply_to_name ) ) {
$reply_to_name = get_bloginfo( 'name' );
}
// If no email is set, use the blog email.
if ( empty( $reply_to_email ) ) {
$reply_to_email = get_bloginfo( 'admin_email' );
}
// Add the reply-to header.
$headers[] = 'Reply-To: ' . $reply_to_name . ' <' . $reply_to_email . '>';
return $headers;
}
add_filter( 'pmpro_email_headers', 'add_reply_to_pmpro_email_headers', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment