• Hi,
    I’m trying to use custom shortcodes (not the ones included by cf7) in the email template. Does anyone have an idea how to do this?

    I tried:
    `function shortcodes_in_cf7( $form ) {
    $form = do_shortcode( $form );
    return $form;
    }
    add_filter( ‘wpcf7_form_elements’, ‘shortcodes_in_cf7’ );`
    But that didn’t work out at all.

    Further I tried creating my own shortcode specially for cf7 like this:

    wpcf7_add_shortcode('custom_shortcode_1', 'wpcf7_custom_shortcode_1_handler', true);
    
    function wpcf7_custom_shortcode_1_handler($tag) {
        if (!is_array($tag)) return '';
    
        $name = $tag['name'];
        if (empty($name)) return '';
    
        $my_shortcode = "some custom content to be displayed by the shortcode";
        $html = '<input type="hidden" name="' . $name . '" value="' . $my_shortcode . '" />';
        return $html;
    }

    and then calling this using [custom_shortcode_1 my_shortcode] in the form and [my_shortcode] in the email, but I don’t like the fact that my shortcode content is loaded in my form, for everyone to be seen.

    Does anyone have a clue how to do this?

    Thanks a lot!

    https://www.ads-software.com/plugins/contact-form-7/

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Use custom shortcodes in email’ is closed to new replies.