• Resolved JarekM

    (@jmilewski)


    Hi there,

    this is just a functionality proposal: send an email notification to the admin when a user changes specific field(s). Could be implemented in back-end as an extra checkbox in the “edit field” sub-form(s) of the “Manage Default and Extra Fields” screen.

    By the way, I implemented this functionality myself by hooking onto wppb_edit_profile_success in class-formbuilder, but I think it might be welcome by many users if it would be available without extra programming.

    The reason is that basic user information such as e.g. billing info, VAT number, country of residence, etc. may require some manual intervention when changed by the user. It’s hard to handle such situations it if no automatic notification exists.

    Regards — Jarek

Viewing 1 replies (of 1 total)
  • Teodor Cosofret

    (@teodor-cosofret)

    Hello Jarek,

    Thank you for reaching out to us.

    This is not a default functionality in Profile Builder but with some custom code we can send a notification to the Admin when a user updates his profile:

    1. Create an empty plugin like this: https://gist.github.com/sareiodata/76f701e01db6685829db

    2. Add the following code to the end of it:

    /*
     * Email administrator after successful edit profile and send the uploaded file. Tags: after edit profile, email administrator, upload field,
     */
    
    add_filter('wppb_edit_profile_success', 'wppb_email_after_edit_4', 10, 3);
      function wppb_email_after_edit_4($request, $form_name, $user_id){
        if ( $form_name == 'edit_profile' ){
            $user_id = get_current_user_id();
        }
    
        $user = get_user_by('id', $user_id);
        $url = admin_url("/user-edit.php?user_id=$user_id");
        $to = get_option( 'admin_email' );
    
        //Replace the custom_field with your own
        $attachement_id = get_user_meta($user_id, "custom_field_1", true);
        $custom_field_input = get_user_meta($user_id, "custom_field_2", true);
        $file = wp_get_attachment_url($attachement_id);
    
        $subject = "User: $user->user_login succesfully edited his account";
        // The message can be modified as you please
        $message = "
    <p>User: $user->user_login succesfully edited his account. View his account at <a href='$url'>his account</a></p>
    <p>User details:</p> 
    <p>Username: $user->user_login </p>
    <p>EMail: $user->user_email </p>
    <p>Custom Field: $custom_field_input </p>
    <p>Uploaded file: $file </p>
    	";
        $headers = "Content-type: text/html";
    
        wp_mail($to, $subject, $message, $headers);
    }

    3. As you can see we can send, to the Admin, the uploaded file (if you use the Upload field), extra fields and default fields. Inside the email the Admin will see the new data added by the user

    4. Install this plugin via FTP (copy it inside wp-content/plugins) or create a zip archive with it and install it via the WordPress plugin upload functionality

    Extra Fields Types are available only in Profile Builder Hobbyist or Pro versions. If you have any other questions about the paid versions please submit a support ticket because we are not allowed to offer support for paid plugins on these free forums.

    Best regards,

Viewing 1 replies (of 1 total)
  • The topic ‘Admin notification on user field change?’ is closed to new replies.