Skip to:
Content
Pages
Categories
Search
Top
Bottom

Display the email address of a user requesting group access in email template


  • chrisleighh
    Participant

    @chrisleighh

    I would like to alter the email template that goes out when a user requests access to a group.
    Right now it shows the username but this is not helpful to our admins because of the ability for users to have whatever name they like. It would be very helpful to be able to include an email token that shows BOTH the display name AND the email address of the person requesting access to the group but I seem unable to find these values.

    Hoping that someone can help me, thanks!

    {{requesting-user.name}} {{requesting-user.name}} {{requesting-user.email}} wants to join the group

    for example… But I don’t think these are valid.

Viewing 4 replies - 1 through 4 (of 4 total)

  • Venutius
    Moderator

    @venutius

    Hi there, according to this: https://codex.buddypress.org/emails/email-tokens/ there’s a global token called {{recipient.username}}. Does that help?


    chrisleighh
    Participant

    @chrisleighh

    Thanks.
    I thought that would be the name of the person receiving the email, no?
    I’m looking for the email recipient to have the email address and display name of the person requesting access to the group.


    shanebp
    Moderator

    @shanebp

    Use the filter to add a token…

    function maybe_add_tokens_bp_email( $formatted_tokens, $tokens, $obj ) {
    
      if ( isset( $formatted_tokens['requesting-user.name'] ) && isset( $formatted_tokens['requesting-user.id'] ) ) {	
    
         $user_info = get_userdata( $formatted_tokens['requesting-user.id'] );
    
         $formatted_tokens['memberemail'] = $user_info->user_email;
    
      }
    
      return $formatted_tokens;
    	
    }
    add_filter( 'bp_email_set_tokens', 'maybe_add_tokens_bp_email', 11, 3  );

    Then edit the Membership request for group email to add that token.
    Something like: Member Email: {{memberemail}}


    chrisleighh
    Participant

    @chrisleighh

    Thanks! Just getting back to this.
    I’ll try this today and let you know.

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