• Resolved dickinsonk9

    (@dickinsonk9)


    Hello,

    I am trying to use a hidden field within CF7 + ACF, and I have successfully been able to replicate it by using these two sections of code:

    echo do_shortcode('[contact-form-7 id="19" destination-email="' . get_field('owner_email') . '"]');

    function custom_shortcode_atts_wpcf7_filter( $out, $pairs, $atts ) {
        $my_attr = 'destination-email';
    
    if ( isset( $atts[$my_attr] ) ) {
        $out[$my_attr] = $atts[$my_attr];
    }
    
    return $out;
    }

    However, I want to be able to still use your plugin in order to add the form as a pop up within my website.

    Is there a hook or a filter that I could use to edit the shortcode printed that is displayed from class.ajax.php?

    • This topic was modified 1 year, 11 months ago by dickinsonk9.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author WPBean

    (@wpbean)

    Hi,

    I just updated the plugin and added a new filter hook for this. Pls use this example PHP code to filter our popup CF7 shortcode.

    Thanks

    add_filter( 'wpb_pcf_form_shortcode', function( $id ){
    	return '[contact-form-7 id="'.$id.'" destination-email="' . get_field('owner_email') . '"]';
    } );
    Thread Starter dickinsonk9

    (@dickinsonk9)

    Thank you so much for this!

    Thread Starter dickinsonk9

    (@dickinsonk9)

    After updating the plugin, copying and pasting your code to the functions.php of the child theme of my site, unfortunately, it breaks in the form box.

    By this, I mean, the form appears, but everything after "'.$id.'" is shown below the form which turns out to be: " destination-email=""]. I know the code you’ve given me is correct theoretically, but I’m not sure why it cut off everything else.

    Plugin Author WPBean

    (@wpbean)

    @dickinsonk9

    The way you customised the CF7 shortcode to set the recipient is seems incorrect to me.

    This is why it’s may showing like this.

    Pls follow this for setting up dynamic recipient for CF7 – https://stackoverflow.com/questions/39953217/contact-form-7-dynamic-recipient-email

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Edit Shortcode for Hidden Attr Field’ is closed to new replies.