Title: Getting Default Values from Shortcode Attributes NOT WORKING (a bug?)
Last modified: March 20, 2019

---

# Getting Default Values from Shortcode Attributes NOT WORKING (a bug?)

 *  [lorinc](https://wordpress.org/support/users/lorinc/)
 * (@lorinc)
 * [7 years, 2 months ago](https://wordpress.org/support/topic/getting-default-values-from-shortcode-attributes-not-working-a-bug/)
 * I am trying to get default values from shortcode attribute but it is not working.
   Setting default value for my dropdown the usual way (e.g. default:2) works as
   expected but when I try to set value from shortcode (e.g. default:myattr) it 
   is not working. My form shortcode is following `[contact-form-7 id=&quot;994&
   quot; title=&quot;Test&quot; myattr=&quot;2&quot;]`, my for content is following`[
   select menu-788 default:myattr &quot;Option1&quot; &quot;Option2&quot; &quot;
   Option3&quot;]` and I have following code in my functions.php:
    `add_filter( ‘
   shortcode_atts_wpcf7’, ‘custom_shortcode_atts_wpcf7_filter’, 10, 3 ); function
   custom_shortcode_atts_wpcf7_filter( $out, $pairs, $atts ) { $my_attr = ‘myattr’;
 *  if ( isset( $atts[$my_attr] ) ) {
    $out[$my_attr] = $atts[$my_attr]; } return
   $out; }`
 * I have tested many combinations (with/without quotes in shortcode, different 
   order…) but no luck.
    -  This topic was modified 7 years, 2 months ago by [lorinc](https://wordpress.org/support/users/lorinc/).
    -  This topic was modified 7 years, 2 months ago by [lorinc](https://wordpress.org/support/users/lorinc/).

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Plugin Author [Takayuki Miyoshi](https://wordpress.org/support/users/takayukister/)
 * (@takayukister)
 * [7 years, 2 months ago](https://wordpress.org/support/topic/getting-default-values-from-shortcode-attributes-not-working-a-bug/#post-11338135)
 * See [Getting Default Values from Shortcode Attributes](https://contactform7.com/getting-default-values-from-shortcode-attributes/)
 *  Thread Starter [lorinc](https://wordpress.org/support/users/lorinc/)
 * (@lorinc)
 * [7 years, 2 months ago](https://wordpress.org/support/topic/getting-default-values-from-shortcode-attributes-not-working-a-bug/#post-11338218)
 * First of all, thanks for the reply.
 * I worked according that for a while and when nothing worked I directly copied
   the code from that page at it still didn’t work. When I tried to see content 
   of the tag using `wpcf7_form_tag` hook i could see that option only contains 
   name of the atribute, not it’s value: `options: Array(1) 0: "default:myattr"`.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Getting Default Values from Shortcode Attributes NOT WORKING (a bug?)’
is closed to new replies.

 * ![](https://ps.w.org/contact-form-7/assets/icon.svg?rev=2339255)
 * [Contact Form 7](https://wordpress.org/plugins/contact-form-7/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/contact-form-7/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/contact-form-7/)
 * [Active Topics](https://wordpress.org/support/plugin/contact-form-7/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/contact-form-7/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/contact-form-7/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [lorinc](https://wordpress.org/support/users/lorinc/)
 * Last activity: [7 years, 2 months ago](https://wordpress.org/support/topic/getting-default-values-from-shortcode-attributes-not-working-a-bug/#post-11338218)
 * Status: not resolved