• tvmk

    (@tuncaycavmak)


    How can I modify below code according to my need?

    My whole intention is that currently in my website I am publishing some brochures and any users to download this brochures should fill the form and submit it. So then, the system should automatically send the brochure download link to their email via Contact Form 7 mail to module. I am currently struggling to find the answer for that.

    Below is the code that I have found in other sites that allows you to create custom mail tag.

    add_filter( 'wpcf7_special_mail_tags', 'wti_special_mail_tag', 20, 3 );
    
    function wti_special_mail_tag( $output, $name, $html )
    {
       // For backwards compatibility
       $name = preg_replace( '/^wpcf7\./', '_', $name );
    
       if ( '_site_url' == $name ) {
          // Get the site url
          $blog_url = get_option( 'siteurl' );
    
                    // Create clickable link
                    $output = make_clickable( $blog_url );
       }
    
       return $output;
    }

    And this code is from my website, users can only download the document after filling to form. So I want to change it to the way i mentioned above.

    <?php if ($info['download']) : ?>
                                <div class="actions">
                                    <a href="#" class="btn btn-icon toggle-single" data-target=".publication-form">
                                        <i class="icon icon-download-dark"></i>
                                        Download
                                    </a>
    
                                    <div class="form publication-form" id="form">
    
                                        <?php echo do_shortcode('[contact-form-7 id="1555" title="Publication"]') ?>
    
                                    </div>
    
                                    <a href="<?php echo $info['download'] ?>" class="btn btn-icon" id="download" style="display: none;">
                                        <i class="icon icon-download-dark"></i>
                                        Download
                                    </a>
    
                                    <iframe id="download_frame" style="display:none;" data-download="<?php echo $info['download'] ?>"></iframe>
                                </div>
                            <?php endif; ?>
  • The topic ‘Contact form 7 custom mail tag’ is closed to new replies.