Hi,
i would use a cleaner code like what is indicated here.
WP function references
wp_mail_from
wp_mail_from_name
BP function references
bp_core_email_from_name_filter
bp_core_email_from_address_filter
NB: please use the code
button when you insert code on this forum.
@steigw does the email link work if you take out your changes, and test?
Is it always broken or only broken when this custom function is in place?
only broken with that custom code, which I found in another post and worked for their theme/bp/wp setup. To try @danbp’s suggestions, I’ll need to find examples where more code is provided.
Can you share the link that you get in the email so we can see what it looks like and where it goes?
It’s a staging site that doesn’t have public access, but I can put the code and info in here. Here is the complete code of the functions.php in the child theme. maybe I just put it all together wrong.
<?php
function nisarg_enqueue_styles() {
$parent_style = 'nisarg-style';
wp_enqueue_style( 'bootstrap', get_template_directory_uri().'/css/bootstrap.css' );
wp_enqueue_style( 'font-awesome', get_template_directory_uri().'/font-awesome/css/font-awesome.min.css' );
wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' );
wp_enqueue_style( 'nisarg-child-style',
get_stylesheet_directory_uri() . '/style.css',
array( $parent_style )
);
}
add_action( 'wp_enqueue_scripts', 'nisarg_enqueue_styles' );
?>
<?php
function custom_wp_mail_from( $email ) {
$handle = ‘accounts’;
$find = 'http://';
$replace = '';
$link = get_bloginfo( 'url' );
$domain = str_replace( $find, $replace, $link );
return $handle . '@' . $domain ;
}
add_filter( 'wp_mail_from', 'custom_wp_mail_from' );
?>
The email link is:http://mydomain.com/activate/JA0BvkK1Q0DND10SYegdOtkTMemhGUF0/
When I click on it immediately, I get all this:
Fatal error: Uncaught exception ‘phpmailerException’ with message ‘Invalid address: ‘accounts’@mydomain.com’ in /homepages/25/d283441938/htdocs/clickandbuilds/staging/wp-includes/class-phpmailer.php:946 Stack trace: #0 /homepages/25/d283441938/htdocs/clickandbuilds/staging/wp-includes/pluggable.php(352): PHPMailer->setFrom(‘\xE2\x80\x98accounts\xE2\x80\x99@…’, ‘WordPress’) #1 /homepages/25/d283441938/htdocs/clickandbuilds/staging/wp-includes/pluggable.php(1726): wp_mail(‘webmaster@arlin…’, ‘[My Dev Sit…’, ‘New user regist…’) #2 /homepages/25/d283441938/htdocs/clickandbuilds/staging/wp-content/plugins/buddypress/bp-members/bp-members-functions.php(2031): wp_new_user_notification(18) #3 /homepages/25/d283441938/htdocs/clickandbuilds/staging/wp-content/plugins/buddypress/bp-members/bp-members-screens.php(364): bp_core_activate_signup(‘JA0BvkK1Q0DND10…’) #4 [internal function]: bp_core_screen_activation(”) #5 /homepages/25/d283441938/htdocs/clickandbuilds/staging/wp-includes/plugin.php(524): cal in /homepages/25/d283441938/htdocs/clickandbuilds/staging/wp-includes/class-phpmailer.php on line 946
If I wait a while, then I get the normal webpage and it says “invalid activation key”. I don’t understand the significance of an immediate click on the link in the email vs. waiting a few more seconds, but it definitely matters.
@danbp had referenced a page with a plug in that wasn’t approved for the version of my wordpress (4.6). I went ahead and tried it and it works great. WP Simple Email Sender (shows as WP Single Email in settings).
I’d love to figure out how to do it the right way, but this seems to fill the bill.