Name and Last Name Variables in HTML Template


I'm using HTML Email Templates, and I would like to use the user's name and last name on the e-mail template. One of the templates has a username variable, so I suppose it's also possible to fetch the first and last name.

Thanks in advance!

  • Adam Czajczyk
    • Support Gorilla

    Hello Pedro,

    I hope you're well today and thank you for your question!

    Currently available placeholders (variables) that you may use in your custom Email Templates are:


    For more explanation on this variables please go to your site's dashboard "Settings -> HTML Email Template" page and click on "List of variables that can be used in template" link.

    I suppose it may be possible to add some more variables with a bit of custom code but I'm not sure (yet) how complex this may be. The "user name" and "last name" - would you like to fetch them from user profile (if a sender's email is associated wit a user account) or from some other source? Could you shed some light on this for me please?

    Best regards,

  • Pedro
    • WPMU DEV Initiate


    Thanks for the lightning fast response. Sorry if I wasn't clear.

    I'd like to fetch it from the user profile. I tried {USER_NAME} and apparently it returns the user's full name. Once this variable isn't on the list, I was wondering if there were any further variables not display in order to personalize the sent e-mails.


  • Adam Czajczyk
    • Support Gorilla

    Hello Pedro,

    Thanks for your replay!

    The {USER_NAME} variable is replaced with WP user "display name" so this may be a nickname/login, first name, last name, both names or anything that user chose in his/her profile as a value of "Display name publicly as" option. I admit I'm not sure why this variable is not on a list. I reviewed the plugin code and it seems that there's no more undocumented variables available though.

    Furthermore, there's no direct hooks in a plugin that could be used to add more variables/placeholders and the only reasonable way I can see would be to hook to core wp "wp_mail()" filter. This would however require custom function to be called after the "wp_mail()" has been modified by plugin and before it was executed. I'd say this would be a bit outside the scope of this forum and would require custom coding for which you may want to ask on our "Jobs & Pros" job board here (please note: no WPMU DEV staff involved!):

    There's a simpler way but it would require changing plugin's code directly which is not recommended and also all these changes would be lost upon first update. If you wish to go this way anyway (please note: this would be at your own risk!) let me know please and hopefully I'll be able to provide you with a code for this.

    Best regards,

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.