• Hello,

    Thanks for a great plugin.

    I am sending a custom field (custom_field-[Name]) that stores an HTML code.
    When CF7 sends the an email it converts HTML entities to characters

    example:

    <b>bold</b>
    shows as
    & l t ; b & g t; bold & l t ; / b & g t;

    I have CF7 “Use HTML content type” ticked

    Thanks in advance

    https://wordpress.org/plugins/contact-form-7-modules/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hey there! Did you sort this out? I’m having the exact same problem!

    Thread Starter gal_op

    (@gal_op)

    Hi r1se,

    I haven’t figure it out yet. I was hoping someone here knows how to achieve this.

    Aww that’s a bummer. This thing’s driving me crazy.

    In the meantime im just adding this to my functions.php

    add_filter('wpcf7_hidden_field_value', 'limpiar_html_cf7hf');
    function limpiar_html_cf7hf($value = '') {
    	$value = esc_html(wp_strip_all_tags( $value ));
    	return $value;
    }

    This will send the custom field content as plaint text.

    I also tried another method:

    function wpcf7_update_email_body($contact_form) {
    
      $submission = WPCF7_Submission::get_instance();
      $url = $submission->get_meta( 'url' );
    
            global $post;
    	$the_post_id = $post->ID;
    
       if ( $submission ) {
       $mail = $contact_form->prop('mail');
       $mail['body'] .= '<p> '. $url .' '. $post.'</p>';
       $contact_form->set_properties(array('mail' => $mail));
      }
    }

    I was trying to get the post id, but it will always return a 0 or nothing. Depends on how I try to get it. If I could get the post id, i would be able to attach the custom field content to the end of the mail’s body. If you are using ACF you could do something like $post = get_field(‘field_name’ , post_id) and that works. I hard coded it and it worked, html was fine on the mail.

    So anyways, please let me know if you find a way to fix this. It would be awesome to render html tags correctly on mail.

    Yes, I’d like to use this feature as well, it’d be a great addition to the plugin.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Custom field – Send as HTML’ is closed to new replies.