How to customize the e-mail notification of a new wordpress user and find out the role of a registered user

In one of the articles, I talked about how to add a user role choice when signing up for WordPress. Now i

I’ll talk about how to customize the e-mail notification of a new wordpress user, so that the site administrator can know what role the new user has registered with.
By default, a new user registration letter contains information:

  • New user name
  • New User Email

In this letter we need to add information about the user role. To do this, edit the system file pluggable.php, which is located:




You need to find the function in it:

function wp_new_user_notification ($ user_id, $ plaintext_pass = ”)

After the line:

$ message. = sprintf (__ (‘Email:% s’), $ user-> user_email). “Rn”;

You need to add the line responsible for the output of the user role:

$ message. = sprintf (__ (‘Role:% s’), $ roles = implode (‘,‘, $ user-> roles)). “Rn”;

Also here you can add any of your text, or a code for displaying any other information about the user.
Now how does it work:

1. The user is registered in our online store and indicates the type of user the wholesaler or retail buyer

2. A letter is sent to the administrator’s mail stating that a new user is registered

Addition: be careful when updating WordPress the pluggable.php file is overwritten and a new one is created. Therefore, save it and when updating, simply replace it, or re-edit it.