• Resolved Make carlos

    (@make-carlos)


    Hi Support team,

    Use HTML content type ( Already checked )-> This is not working and i can see Table in email. as I am adding my code using my custom shortcode.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Takayuki Miyoshi

    (@takayukister)

    Where can we see the website in question?

    Thread Starter Make carlos

    (@make-carlos)

    Hi

    its custom plugin in which i am working. I have some custom Data which i want to send in Email. as all data set using Table.

    And yeah sorry i was forgot to say that i have used plugin : Contact Form 7 Dynamic Text Extension

    So is there any way to do using filter and no need to use above plugin. Please advice.

    Thanks

    Plugin Author Takayuki Miyoshi

    (@takayukister)

    Thread Starter Make carlos

    (@make-carlos)

    Okay so i have disabled that third party plugin and now doing with CF7 Filters.

    here is my code.

    add_filter('wpcf7_mail_components','my_custom_mail', 10,2);
    function my_custom_mail($mail_component, $contact_form){
    	$domain_data = do_shortcode( '[g4whostingdata]' );
        if($wpcf7->id() == 6){
            $mail_component['subject']; //email subject
            $mail_component['sender']; //sender field (from)
            $mail_component['body']; //email body
            $mail_component['recipient']; //email recipient (to)
            $mail_component['additional_headers']; //email headers, cc:, bcc:, reply-to:
            $mail_component['attachments']; //file attachments if any
    
            $key_values = array();
            $tags = $contact_form->scan_form_tags(); //get your form tags
            foreach($tags as $tag){
                $field_name  = $tag['name'];
                if(isset($_POST[$field_name]) && !empty($_POST[$field_name])){
                  //get all the submitted fields form your form
                    $key_values[$field_name] = $_POST[$field_name]; 
                }
            }
    
            $body = "Dear \n" 
                    . "First Name: {$key_values['first-name']} \n"
                    . "Last name: {$key_values['last-name']} \n"
                    . "Email: {$key_values['your-email']} \n"
                    .  "Domain Data : {$domain_data} \n";
    
            $mail_component['body'] = $body;
        }
        return $mail_component;
    }

    I have set FORM ID but its showing Internal server errors and form is not submitted. could you please advice.

    Thanks

    Thread Starter Make carlos

    (@make-carlos)

    Okay so look like i have fixed. This will helps to others.

    // define the wpcf7_mail_components callback

    function filter_wpcf7_mail_components( $components, $number )
    {
    	$contact_form = WPCF7_ContactForm::get_current();
    	$contact_form_id = $contact_form -> id;
    
      if($contact_form_id == 6){
      $components[ 'subject' ] = 'New Domain request from customer';
       $components[ 'body' ] = $components['body'];
       $components[ 'body' ] .= do_shortcode( '[g4whostingdata]' );
    return $components;
    	  }
    };
    
    // add the filter
    add_filter( 'wpcf7_mail_components', 'filter_wpcf7_mail_components', 10, 2 );

    But my question is why HTML tags are not supported even i have selected from settings. I have Table structure in Short code but its showing table tags in email.

    Please advice.

    Thanks

    Thread Starter Make carlos

    (@make-carlos)

    Hi @takayukister,

    did you checked my last comment.I have said this:

    But my question is why HTML tags are not supported even i have selected from settings. I have Table structure in Short code but its showing table tags in email.

    Please advice.

    Don’t know why you made this thread as resolved !
    Thanks

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Use HTML content type – not working with custom shortcode’ is closed to new replies.