Problem: I would like to use a Form to delete a User. When the Form is submitted successfully, I would like to send an email to that User's address.
Solution: Add a generic hidden field to the Form and call it something like "generic-email-field". Set the value to be the current User's email, like this:
[cred_generic_field type='hidden' field='generic-email-field']
{
"required":0,
"validate_format":0,
"default":"[wpv-user field='user_email']"
}
[/cred_generic_field]
Then in the notification settings, I would choose "Send notification to a specific email address" and enter something like support@yoursite.com, where all these messages will be sent. Then you can use the cred_notification_recipients API to add the generic field address as a CC, like this:
add_filter('cred_notification_recipients', 'modify_recipients', 10, 4);
function modify_recipients($recipients, $notification, $form_id, $post_id) {
// Check notification name matches target notification
if ( isset($notification['name']) && 'Your notification name' == $notification['name'] ) {
// Add a CC to the generic email address
$recipients[] = array(
'to' => 'cc',
'address' => $_POST['generic-email-field'],
'name' => '',
'lastname' => ''
);
}
return $recipients;
}
Change Your notification name to match your notification name.
Relevant Documentation:
https://toolset.com/documentation/programmer-reference/cred-api/#cred_notification_recipients