Membership 2 adding BuddyPress fields to email templates

I want to add BuddyPress custom fields to email templates at the Settings > Automated Email Responses to "Signup - user account created" template. How can I do that?

  • Ivan

    Hi Andra !

    You could try adding the following snippet in a MU plugin ( more info about MU plugins is here )

    <?php
    function wpmu_membership_add_bb_profile_fields( $comm_vars, $type, $member, $subscription ) {
        if ( 'type_signup' === $type ) {
            $comm_vars['%BB-website%'] = '';
            $comm_vars['%BB-city%'] = '';
        }
        return $comm_vars;
    }
    add_filter( 'ms_model_communication_comm_vars', 'wpmu_membership_add_bb_profile_fields', 10, 4 );
    
    add_filter( 'ms_model_communication_send_message_comm_var-%BB-website%', function( $var_value, $type, $member, $subscription, $invoice ) {
        if ( 'type_signup' === $type ) {
            $var_value = xprofile_get_field_data( 7, $member->id );
        }
        return $var_value;
    } );
    add_filter( 'ms_model_communication_send_message_comm_var-%BB-city%', function( $var_value, $type, $member, $subscription, $invoice ) {
        if ( 'type_signup' === $type ) {
            $var_value = xprofile_get_field_data( 4, $member->id );
        }
        return $var_value;
    } );

    Note: this code will work only for website and city fields - you can add other BuddyPress fields in a similar way.
    Note: you should replace 4 and 7 numbers to real IDs of the BuddyPress fields. You can see it in the address line on Edit page of these fields. For example, it's 3 for Address field

    Unfortunately, I couldn't test it on your site because it seems FTP credentials which you provided is incorrect. Could you check it and provide it again?

    https://premium.wpmudev.org/contact/#i-have-a-different-question
    Please visit our private Contact page and complete the form with the following information:

    Subject: "Attn: Ivan Svyrskyi"

    In the Message box, please provide the following:

    link back to this thread for reference
    any other relevant urls

    FTP/SFTP credentials
    host
    username
    password
    (and port if required)

    Note: Don't send any credentials via this forum because it's public forum.

    Best,
    Ivan.