Skip to:

Send Admin Notification when User Updates specific Profile Field

  • honoluluman


    I would like to create a simple email send to admin when a user updated a specific Profile Field.
    The field is a checkbox so it should be an array because a have multiple values.

    The code that i alreade try to use is

    function buddypress_profile_update( $user_id ) { 
         $admin_email = "YOUR-EMAIL@DOMAIN.COM";
         $message = sprintf( __( 'Member: %1$s', 'buddypress' ), bp_core_get_user_displayname( $user_id ) ) . "\r\n\r\n"; 
         $message .= sprintf( __( 'Color: %s' ), bp_get_profile_field_data('field=Color') ). "\r\n\r\n";
         wp_mail( $admin_email, sprintf( __( '[YOUR SITE] Member Profile Update' ), get_option('blogname') ), $message );
     add_action( 'xprofile_updated_profile', 'buddypress_profile_update', 10, 5 );

    1st Problem. In the email i get just “Color: Array” , i have tried to use vsprintf instead but it gives me back only one value.

    2d Problem. I get an email whenever there is an update in general, and not only when there is an update from the specific field with ID 7.

    Any help would be appreciated.

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

  • Lars Henriksen


    I would like something like this as well… have you found a code snippet that does the trick?

    Cheers, Lars



    @adjunkten You can use the below:

    function profile_field_update( $user_id, $posted_field_ids, $errors, $old_values, $new_values ) {
    if ($old_values[4]['value'] !== $new_values[4]['value']) {
         $message = sprintf( 'The user: <strong>%1$s</strong> changed his profile field with ID number 4' , bp_core_get_user_displayname( $user_id ) ) . "<br><br>"; 
         wp_mail( $admin_email, $title, $message );
    add_action( 'xprofile_updated_profile', 'profile_field_update', 10, 5 ); 

    This is just an example how the admin can be notified via email when the user change a specific profile field of him. In the example the profile field has ID with number 4.

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