Thank you for sharing these details.
For these very specific requirements, you'll need to add some code customization.
On my test website, I was able to achieve this using the following steps:
1. In my user edit form (ID: 156), I included a WYSIWYG type field with slug 'user-desc-2'.
2. In the same form, I also included a 'hidden' type generic field with slug 'user-desc-2-current'.
For this field's default value field, I used the shortcode that gets the current value of the WYSIWYG 'user-desc-2' field.
( ref: https://toolset.com/documentation/customizing-sites-using-php/functions/#wysiwyg )
[types usermeta='user-desc-2' user_current='true' suppress_filters='true' output='raw'][/types]
This hidden field will help in comparing the values of the field, before and after the form has been submitted.
3. As a last step, I used a custom function attached to the 'cred_notification_recipients' hook.
( ref: https://toolset.com/documentation/programmer-reference/cred-api/#cred_notification_recipients )
This function will make sure that the target form's specific notification ( in this case 'Test notification' ), is only sent if, before and after values of the field are different and one of them is empty:
add_filter('cred_notification_recipients', 'modify_recipients_empty_field_check', 10, 4);
function modify_recipients_empty_field_check($recipients, $notification, $form_id, $user_id) {
// Check notification name and form ID matches target notification name and form ID
if ( ( isset($notification['name']) && 'Test notification' == $notification['name'] ) && ( $form_id == 156 ) ) {
// if current and previous values for the target field are different and one of them is empty, send notification
if( ($_POST['wpcf-user-desc-2'] != $_POST['user-desc-2-current']) && ((empty($_POST['wpcf-user-desc-2'])) || (empty($_POST['user-desc-2-current']))) )
{
return $recipients;
}
}
else {
return $recipients;
}
}
Note: You'll need to update the form ID, form notification name and the field slugs used in this code snippet to match the ones from your website.
The above code snippet can be included through either Toolset's custom code feature ( ref: https://toolset.com/documentation/adding-custom-code/using-toolset-to-add-custom-code/ ) or through the active theme's "functions.php" file.
I hope this helps and for more personalized assistance around custom code, you can also consider hiring a professional from our list of recommended contractors:
https://toolset.com/contractors/