i want Send Custom welcome Email to specific user group
also i build a real estate site , and i want when a new buyer register to the buyer user group , also i want Custom email to be sent to him with some information ...
also i have already add this cod to the sb_welcome_email_editor but it don't work
// Change "from" email
add_filter( 'wp_mail_from', 'new_mail_from_name' );
function new_mail_from_name() {
return '[email protected]';
}
// Change "from" name
add_filter( 'wp_mail_from_name', 'new_mail_from' );
function new_mail_from() {
return 'Your site';
}
can you help on this please ?
i want Send Custom welcome Email to specific user group
also i build a real estate site , and i want when a new buyer register to the buyer user group , also i want Custom email to be sent to him with some information ...
also i have already add this cod to the sb_welcome_email_editor but it don't work
// Change "from" email
add_filter( 'wp_mail_from', 'new_mail_from_name' );
function new_mail_from_name() {
return '[email protected]';
}
// Change "from" name
add_filter( 'wp_mail_from_name', 'new_mail_from' );
function new_mail_from() {
return 'Your site';
}
can you help on this please ?
Share Improve this question edited May 21, 2020 at 9:05 fuxia♦ 107k38 gold badges255 silver badges459 bronze badges asked May 21, 2020 at 3:44 Safrout lahmarSafrout lahmar 111 bronze badge1 Answer
Reset to default 0You have your functions mixed up - the new_mail_from is for the address, not the name, and the new_mail_from_name is for the name, not the address.
Also, WordPress changed the tests for users/groups from the old Roles to the new Capabilities so assuming your "buyer" user group has some specific Capability you can target then you could do something like this:
// Change default WordPress email address for Buyers
if(current_user_can( 'something_only_buyers_can_do' ) {
function new_mail_from($old) {
return '[email protected]';
}
function new_mail_from_name($old) {
return 'Your Site';
}
add_filter('wp_mail_from', 'new_mail_from');
add_filter('wp_mail_from_name', 'new_mail_from_name');
}
You could still try using the old Roles but no telling how long that will work, using Capabilities is more future-proof.