Strip textarea breaklines on Email 2 message
-
Hello, I need to clean the textarea message of a CF7 form in order to avoid multiple lines in the text.
I use the following function:
function wpcf7_textarea_strip_tags($WPCF7_ContactForm) { //Get current form $wpcf7 = WPCF7_ContactForm::get_current(); // get current SUBMISSION instance $submission = WPCF7_Submission::get_instance(); // Ok go forward if ($submission) { // get submission data $data = $submission->get_posted_data(); // nothing's here... do nothing... if (empty($data)) { return; } $text = isset($data['contact-form-message']) ? $data['contact-form-message'] : ""; $text = preg_replace('/\s+/', ' ', $text); // or $text = preg_replace("/\r|\n/", " ", $text); $mail = $wpcf7->prop('mail'); $mail['body'] = str_replace('[contact-form-message]', $text, $mail['body']); // Save the email body $wpcf7->set_properties(array( "mail" => $mail )); // return current cf7 instance return $wpcf7; } } add_action("wpcf7_before_send_mail", "wpcf7_textarea_strip_tags");
This code is working for the email message from the “EMAIL 1”, but not from “EMAIL 2” (this one, still contain the message with breaklines).
How can I solve this? I need this as the Email 2 is connected to an external CRM that parse each single lines as field values
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Strip textarea breaklines on Email 2 message’ is closed to new replies.