0

I have a user dashboard where customers can login and view invoices etc.

When I put their invoice details it, WordPress automatically creates an account and generates a password and sends a welcome email.

The problem is that the email is very basic and I want to give it my own wording.

I have seen ways of editing different WordPress default emails but cannot find a way of editing this particular one, even with plugins.

the email reads:

Your Access Credentials [http://www.website.co.uk]

Dear customer,

we have set an account for you on http://s692312552.websitehome.co.uk. You are able to login now using the following credentials:

URL: http://www.website.co.uk/login/
Login: webmaster@email.co.uk
Password: X5USOGgLhjBo

I am looking for a way to edit the email content so I can have my own content added.

I have searched online and also installed the plugin '
Better Notifications for WordPress' but cannot find anything related to this particular email

Ideally, I would like to use a template like:

<p>Dear customer,</p>

<p>we have set an account for you on <span style="font-weight: bold;"><a href="https://www.website.co.uk">website</a></span>.</p>

<p>You can use this account to update your information.</p>
<div style="width: 90%; margin-left: 5%; background-color: #edf2f7; text-align: center; padding: 15px 0;">

<p>Your Login Credentials are:</p>

<p><span style="font-weight: bold;">Login:</span> [email_user_email]</p>

<p><span style="font-weight: bold;">Password:</span> [password]</p>

</div>
<p>To access your account and update your password you can login <a href="https://www.website.co.uk/my-account">here</a></p>

<p>Kind Regards</p>

<p>website Accounts</p>

Any help would be great

SupGen
  • 195
  • 17

1 Answers1

0

Replace the code between lines 649 and 656

      global $wpi_settings;
      if ( is_int( $user_id ) && WPI_Functions::is_true( $wpi_settings['send_password_to_new_users'] ) ) {

        $subject = 'Your Access Credentials ' . get_bloginfo('url');
        $body = '<p>Dear Customer,</p>';
        $body .= '<p>we have set an account for you on <span style="font-weight: bold;"><a href="'.get_bloginfo('url').'">'.ud_get_wp_invoice()->domain.'</a></span>.</p>';
        $body .= '<p>You can use this account to update your information.</p>';
        $body .= '<div style="width: 90%; margin-left: 5%; background-color: #edf2f7; text-align: center; padding: 15px 0;"> ';
        $body .= '<p>Your Login Credentials are:</p>';
        $body .= '<p><span style="font-weight: bold;">Login: </span>'.$userdata[ 'user_login' ].'</p>';
        $body .= '<p><span style="font-weight: bold;">Password: </span>'.$userdata[ 'user_pass' ].'</p>';
        $body .= '</div>';
        $body .= '<p>To access your account and update your password you can login <a href="'.get_bloginfo('url').'/my-account">here</a></p>';
        $body .= '<p>Kind Regards,</p><p>website Accounts</p>';

        //added a blind carbon copy to the headers so you can easily debug
        $headers[]= "Bcc: [YOU] <your@email.com>";

        wp_mail($userdata[ 'user_email' ],$subject,$body,$headers);
      }
dan webb
  • 626
  • 1
  • 5
  • 9
  • thanks for your reply Dan. However, it is not the sender info I am looking to change, I have already done that. My issue is the actual information that appears within the message which wordpress sends by default. I have checked the pluggable.php file. however, I cannot see the particular email that I am looking for. In the pluggable.php file you can see all the subject headers, ie. new password etc... but I cannot see the subject - 'Your Access Credentials [http://www.website.co.uk]'. id like to change the message content for that particular email and potentially a few others. – SupGen Feb 08 '19 at 22:47
  • Im not sure. I have been looking at the pluggable.php file and cannot find the specific email. Hoping someone can clarify things for me. – SupGen Feb 09 '19 at 08:13
  • Is the user account being created via the invoice plugin? Which plugin is it? I will investigate more today. I think my answer is still the right one but just need to add some more logic to the $message var – dan webb Feb 09 '19 at 14:39
  • I never actually thought of that. When I generate the invoice, I add their email which adds them as a user on wordpress and sends out their login details. The plugin is WP-Invoice – SupGen Feb 09 '19 at 16:29
  • 1
    I have found it... https://github.com/wp-invoice/wp-invoice/blob/latest/lib/class_functions.php starts line:649 although not sure how to ammend myself, any help would be amazing – SupGen Feb 09 '19 at 16:52
  • See my updated answer. The lines of code to replace are part of a larger function so consider some debugging to ensure the function still works correctly. Make sure you do not update the plugin without taking consideration for how to preserve this code in the future. – dan webb Feb 09 '19 at 17:17
  • Ill try that, thanks. if i update the core file, when the plugin updates, it will override the code. would I be ble to add this as a plugin override? – SupGen Feb 09 '19 at 17:20
  • There isnt really a simple clean way to handle this. If the author of wp-invoice makes this function filterable in the future you could override it in the functions.php but for now, this is really the best solution other than manually replacing the email function with this code every plugin update https://stackoverflow.com/a/33148644/7077417 – dan webb Feb 09 '19 at 17:24