Support » Plugin: Members - Membership & User Role Editor Plugin » Trying to add user role short code to new order email

  • I’m trying to figure out how to add some code to my functions.php file to let me add a user role shortcode to new order emails. I had posted a direct follow-up question to this forum post in reference to the code provided by @caseproof which worked on a test page, but not my order email but my post was deleted by a moderator. Here’s the link to the original topic: Hopefully he or someone can see it now. Anyway, I had provided some examples of how I was trying to use the code:


    Does anyone have any advice on how to get a user role shortcode in my new order emails?


    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Caseproof


    Hi @pogle

    I noticed in your screenshot that you have some built-in shortcodes that can be used like this: {customer_email}, so I believe that regular shortcodes like [mb-user-role] shortcode might not work as expected. I’m not sure which plugin/theme you use to add shortcodes to emails but you need to ask plugin/theme author how to add custom shortcode. Then, you can use the shortcode from previous thread, but since you are using it inside email, you need to replace this line:

    $user = wp_get_current_user();

    with this:

    $user = get_user_by( 'email', '' );

    and change with user email.

    Hopefully, that helps.

    Thread Starter pogle


    thanks, I’ll check with that plugin dev to see what they say, but if I change the ‘’ email with the user’s email, in the functions.php, I can’t imagine that would be the best way to go about it with thousands of existing and new users placing orders?

    • This reply was modified 3 months, 2 weeks ago by pogle.
    Plugin Author Caseproof


    The was just an example of an email. You should replace it with customer email. I noticed that there is {customer_email} shortcode so that plugin that gives this functionality has some way to grab customer email. You could use the same functionality to replace with current customer email.

    Hopefully, that helps.

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.