Skip to:
Content
Pages
Categories
Search
Top
Bottom

New member profile data inc. in ‘new user reg.-email’?


  • Lars Henriksen
    Participant

    @adjunkten

    When a new user registers, I log in and screenshot the user’s extended profile and send it to our accountant. Silly, I know.

    Is there any way to include the new user’s xprofile data in the ‘new user’-mail ?

    thanks, Lars

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

  • Bharat
    Participant

    @chavodbharat

    Hi Lars

    you can use email token name while https://codex.buddypress.org/emails/email-tokens/ .


    Lars Henriksen
    Participant

    @adjunkten

    Thanks for answering, but there are no tokens for custom xprofile fields?


    Prashant Singh
    Participant

    @prashantvatsh

    It will be custom work. You can add this code snippet in your child theme’s functions.php to achieve this:

    add_filter('bp_core_signup_send_validation_email_message','ps_user_data_to_email',10,2);
    function ps_user_data_to_email( $msg, $user_id )
    {
      $user = get_user_by( 'id', $user_id );
      if(!empty($user))
        $data1 =  xprofile_get_field_data('your_first_field_name',$user->ID);
        echo 'Your Profile Field Name'. ' : '.$data1;
        $data2 =  xprofile_get_field_data('your_second_field_name',$user->ID);
        echo 'Your Profile Field Name'. ' : '.$data2;
    }

    You can do this for all the profile fields by just repeating the code to get data3 data4 like I did for data1 data2 and obviously you have to use your profile fields name in place of ‘your_first_field_name’, ‘your_second_field_name’ and ‘Your Profile Field Name’.

    Thanks


    Lars Henriksen
    Participant

    @adjunkten

    Thank you for helping me, Prashant Singh.

    I tried this on my on my staging site,

    add_filter('bp_core_signup_send_validation_email_message','ps_user_data_to_email',10,2);
    function ps_user_data_to_email( $msg, $user_id )
    {
      $user = get_user_by( 'id', $user_id );
      if(!empty($user))
        $data1 =  xprofile_get_field_data('Navn',$user->ID);
        echo 'Navn'. ' : '.$data1;
        $data2 =  xprofile_get_field_data('Postnr._og_by',$user->ID);
        echo 'Adresse 2'. ' : '.$data2;
    }

    but the ‘new user email’ stays the same – username and email included and nothing else.
    Is the syntax wrong? I just replaced spaces with ‘_’ in field names. Is ‘.’ allowed? (data2)

    Cheers


    Prashant Singh
    Participant

    @prashantvatsh

    No, please write the field name exactly it is there in xprofile field. You can also use field id instead the name.

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