Support » Plugin: Contact Form 7 » Second Shortcode Attribute needed

  • Resolved manuka

    (@manuka)


    Hello,

    I use Shortcode Attributes as in:
    https://contactform7.com/getting-default-values-from-shortcode-attributes/
    -> which is working perfectly fine so far.
    But now I need a second Shortcode Attribute for the same form.

    Could you please be so kind as to provide the additional code which I have to put in the function.php? I cannot figure out, where and how to add the second attribute (which might for example be named “subject”) in the function:

    add_filter( ‘shortcode_atts_wpcf7’, ‘custom_shortcode_atts_wpcf7_filter’, 10, 3 );

    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;
    }

    I tried a few things, but didnt work.. (I am not a php-expert :-/)

    Thank you very much for your help
    manuka

Viewing 1 replies (of 1 total)
  • ok, solved it now…
    🙂

    In case anyone interested:

    add_filter( ‘shortcode_atts_wpcf7’, ‘custom_shortcode_atts_wpcf7_filter’, 10, 3 );

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

    add_filter( ‘shortcode_atts_wpcf7’, ‘custom_shortcode_atts_wpcf7_filter2’, 10, 3 );

    function custom_shortcode_atts_wpcf7_filter2( $out, $pairs, $atts ) {
    $my_attr2 = ‘subject’;
    if ( isset( $atts[$my_attr2] ) ) {
    $out[$my_attr2] = $atts[$my_attr2];
    }
    return $out;
    }

Viewing 1 replies (of 1 total)
  • The topic ‘Second Shortcode Attribute needed’ is closed to new replies.