top of page

Using Dynamic Values in Contact Form 7

  • Writer: سُلَيْمَان بْن دَاوُوْد
    سُلَيْمَان بْن دَاوُوْد
  • Jun 6, 2020
  • 1 min read

This is one of cool features like we have a site where we have surgeons stored in custom post type and each surgeon has its own detail page and corresponding appointment form so if there are 100 surgeon we are not going to create 100 forms so here is the cup of tea.



/*Add dynamic value to contact form 7*/
add_filter( 'shortcode_atts_wpcf7', 'custom_shortcode_atts_wpcf7_filter', 10, 3 );
function custom_shortcode_atts_wpcf7_filter( $out, $pairs, $atts ) {
    $customattr = 'destination-email';
 
    if ( isset( $atts[$customattr] ) ) {
        $out[$customattr] = $atts[$customattr];
    }
     return $out;
}
/*Add dynamic value to contact form 7*/

The code on the template file 



The contact form field in green




Recent Posts

See All
Hide Upcoming Events

Hiding Upcoming Events can be relatively useful when you are using ACF fields to show Dates for an an Event The Following Snippet is an...

 
 
 

Comments


© 2020 by syednazrulhassan

bottom of page