Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ipokkel/75a69865ba79ab015a502e4b3aa9fbbd to your computer and use it in GitHub Desktop.
Save ipokkel/75a69865ba79ab015a502e4b3aa9fbbd to your computer and use it in GitHub Desktop.
Replace double backslashes before apostrophe in the email From Name and replace apostrophe html code with an apostrophe in the sitename email placeholder variable.
<?php
/**
* Fix apostrophe's used in the from name and sitename email variable in emails.
*
* 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 pmpro_email_sender_name_remove_double_backslashes( $from_name ) {
return str_replace( '\\', '', $from_name );
}
add_filter( 'pmpro_email_sender_name', 'pmpro_email_sender_name_remove_double_backslashes' );
function pmpro_email_data_sitename_replace_apostrophe( $data ) {
$data['sitename'] = str_replace( '&#039;', "'", $data['sitename'] );
return $data;
}
add_filter( 'pmpro_email_data', 'pmpro_email_data_sitename_replace_apostrophe' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment