1

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 ?

1 Answer 1

0

You 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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.