Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #1495693

    Hallo Support-Team,

    ich möchte die automatische Kopie der Formulardaten in der Bestätigungs-E-Mail an den Absender deaktivieren.

    Ich habe bereits folgenden Filter in der functions.php meines Child-Themes ausprobiert:

    PHP
    add_filter('avf_form_autoresponder_copy', 'remove_form_copy_from_autoresponder', 10, 1);
    function remove_form_copy_from_autoresponder($copy) {
        return false;
    }

    Leider werden die Formulardaten weiterhin unterhalb meines benutzerdefinierten Bestätigungstextes in der E-Mail an den Absender mitgesendet. Ich verwende den Standard Avia Layout Architekten für das Kontaktformular.

    Die E-Mail an den Administrator soll weiterhin alle Daten enthalten. Gibt es eine aktuellere Methode oder einen anderen Hook, um den Anhang der Formulardaten im Autoresponder zu unterdrücken?

    Vielen Dank für eure Hilfe!

    #1495715

    Hey tebitron,

    Thank you for the inquiry.

    You can use this filter in the functions.php file to strip down the form data from the autoresponder message.

    add_filter( 'avf_contact_form_autoresponder_mail', function( $mail_array, $new_post, $form_params, $form_obj ) {
        if( isset( $mail_array['Message'] ) ) {
            $marker = '<strong>' . __( 'Your Message:', 'avia_framework' ) . '</strong>';
            $pos = strpos( $mail_array['Message'], $marker );
    
            if( $pos !== false ) {
                $mail_array['Message'] = rtrim( substr( $mail_array['Message'], 0, $pos ) );
            }
        }
        return $mail_array;
    }, 10, 4 );
    

    Best regards,
    Ismael

    #1495731

    Unfortunately, that didn’t do the job. What am I missing?

    The autoresponder message still appears the same way.

    #1495755

    Hi,

    Thank you for the update.

    In the avf_contact_form_autoresponder_mail filter, you have to translate “Your Message:” text to German.

    add_filter( 'avf_contact_form_autoresponder_mail', function( $mail_array, $new_post, $form_params, $form_obj ) {
        if( isset( $mail_array['Message'] ) ) {
            $marker = '<strong>' . __( 'Ihre Nachricht:', 'avia_framework' ) . '</strong>';
            $pos = strpos( $mail_array['Message'], $marker );
    
            if( $pos !== false ) {
                $mail_array['Message'] = rtrim( substr( $mail_array['Message'], 0, $pos ) );
            }
        }
        return $mail_array;
    }, 10, 4 );

    Let us know how it goes.

    Best regards,
    Ismael

    #1495765

    Hi Ismael,

    nope. Not yet. Still looks the same.

    Kind regards.

    #1495806

    Hi,

    Thank you for the update.

    Is the following text actually included in the email?

    ###### Everything below this line shouldn’t appear ######
    

    Try to use this filter instead.

    add_filter( 'avf_contact_form_autoresponder_mail', function( $mail_array, $new_post, $form_params, $form_obj ) {
        if ( ! isset( $mail_array['Message'] ) ) {
            return $mail_array;
        }
    
        $message = $mail_array['Message'];
    
        $separators = [ '<hr', '&#8212;&#8212;&#8212;' ];
    
        foreach ( $separators as $sep ) {
            $pos = strpos( $message, $sep );
    
            if ( $pos !== false ) {
                $mail_array['Message'] = rtrim( substr( $message, 0, $pos ) );
                return $mail_array;
            }
        }
    
        $pattern = '/<br\s*\/?>\s*(?:Ihre Nachricht:|Anrede|Vorname|Nachname|E-Mail|Thema|Nachricht)\s*:?/i';
    
        if ( preg_match( $pattern, $message, $matches, PREG_OFFSET_CAPTURE ) ) {
            $mail_array['Message'] = rtrim( substr( $message, 0, $matches[0][1] ) );
        }
    
        return $mail_array;
    }, 10, 4 );
    

    Best regards,
    Ismael

    #1495812

    Hi Isamel,

    awesome – it looks much better. Thanks.

    And yes, that part is not supposed to be in the email either – that was just for your information.

    The only remainder I’d love to remove is “Ihre Nachricht:” – that’s still coming through.

    Kind regards.

    #1495837

    Hi,
    Try this instead:

    add_filter( 'avf_contact_form_autoresponder_mail', function( $mail_array, $new_post, $form_params, $form_obj ) {
        if ( ! isset( $mail_array['Message'] ) ) {
            return $mail_array;
        }
    
        $message = $mail_array['Message'];
    
        $separators = [ '<hr', '———' ];
    
        foreach ( $separators as $sep ) {
            $pos = strpos( $message, $sep );
    
            if ( $pos !== false ) {
                $mail_array['Message'] = rtrim( substr( $message, 0, $pos ) );
                return $mail_array;
            }
        }
    
        $pattern = '/<br\s*\/?>\s*(?:Ihre Nachricht|Anrede|Vorname|Nachname|E-Mail|Thema|Nachricht)\s*:?/i';
    
        if ( preg_match( $pattern, $message, $matches, PREG_OFFSET_CAPTURE ) ) {
            $mail_array['Message'] = rtrim( substr( $message, 0, $matches[0][1] ) );
        }
    
        return $mail_array;
    }, 10, 4 );

    Or this:

    add_filter( 'avf_contact_form_autoresponder_mail', function( $mail_array, $new_post, $form_params, $form_obj ) {
        if ( ! isset( $mail_array['Message'] ) ) {
            return $mail_array;
        }
    
        $message = $mail_array['Message'];
    
        $separators = [ '<hr', '———' ];
    
        foreach ( $separators as $sep ) {
            $pos = strpos( $message, $sep );
    
            if ( $pos !== false ) {
                $mail_array['Message'] = rtrim( substr( $message, 0, $pos ) );
                return $mail_array;
            }
        }
    
        $pattern = '/(?:<br\s*\/?>)?\s*Ihre Nachricht\s*:?|<br\s*\/?>\s*(?:Anrede|Vorname|Nachname|E-Mail|Thema|Nachricht)\s*:?/i';
    
        if ( preg_match( $pattern, $message, $matches, PREG_OFFSET_CAPTURE ) ) {
            $mail_array['Message'] = rtrim( substr( $message, 0, $matches[0][1] ) );
        }
    
        return $mail_array;
    }, 10, 4 );

    Best regards,
    Mike

    #1496165

    Thanks a lot Mike. That worked well.

    Best regards.

Viewing 9 posts - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.