Hi, the following script will allow %userdataXXX% variable in second email subject and body, as well as some other variables:
if (!function_exists('wfu_before_email_notification_handler')) {
function wfu_before_email_notification_handler($changable_data, $additional_data) {
global $blog_id;
$user = wp_get_current_user();
if ( 0 == $user->ID ) {
$user_login = "guest";
$user_email = "";
}
else {
$user_login = $user->user_login;
$user_email = $user->user_email;
}
$notifyrecipients = "[email protected]";
$notifysubject = "New File Uploaded";
$notifymessage = "Hello\n\nCustomer $user_login has sent you some files\n\nRegards";
$notifyheaders = "";
$search = array ('/%username%/', '/%useremail%/', '/%filename%/', '/%filepath%/', '/%blogid%/');
$replace = array ($user_login, ( $user_email == "" ? "no email" : $user_email ), $changable_data["filename"], $changable_data["filepath"], $blog_id);
foreach ( $changable_data["user_data"] as $userdata_key => $userdata_field ) {
$ind = 1 + $userdata_key;
array_push($search, '/%userdata'.$ind.'%/');
array_push($replace, $userdata_field["value"]);
}
$notifysubject = preg_replace($search, $replace, $notifysubject);
$notifymessage = preg_replace($search, $replace, $notifymessage);
$notify_sent = wp_mail($notifyrecipients, $notifysubject, $notifymessage, $notifyheaders);
return $changable_data;
}
add_filter('wfu_before_email_notification', 'wfu_before_email_notification_handler', 10, 2);
}
Regards
Nickolas