Title: Checkbox shortcode with multiple default values
Last modified: January 5, 2025

---

# Checkbox shortcode with multiple default values

 *  [friedchickin](https://wordpress.org/support/users/friedchickin/)
 * (@friedchickin)
 * [1 year, 5 months ago](https://wordpress.org/support/topic/checkbox-shortcode-with-multiple-default-values/)
 * Hi!
 * Is it possible to select multiple checkbox values in a shortcode tag?
 * My current setting:
 * Shortcode on different pages **with** **different default values**:
 *     ```wp-block-code
       [contact-form-7 id="xxxxxxx" title="ContactForm1" wpcf7_chkbox_products1="Value3" wpcf7_chkbox_products2="Value2"]
       ```
   
 * Form with checkboxes:
 *     ```wp-block-code
       ...[checkbox wpcf7_chkbox_products1 default:shortcode_attr "Value1" "Value2" "Value3" "Value4"][checkbox wpcf7_chkbox_products2 default:shortcode_attr "Value1" "Value2"]...
       ```
   
 * functions.php:
 *     ```wp-block-code
       add_filter( 'shortcode_atts_wpcf7', 'custom_shortcode_atts_wpcf7_filter', 10, 3 );function custom_shortcode_atts_wpcf7_filter( $out, $pairs, $atts ) {  $my_attr = ['wpcf7_chkbox_products1', 'wpcf7_chkbox_products2'];  foreach ( $my_attr as $key => $value ) {    if(isset($atts[$value]))    {      $out[$value] = $atts[$value];    }  }  return $out;}
       ```
   
 * This works properly for one default value to be checked!
 * **But how can I select multiple default values?**
   Example: wpcf7_chkbox_products1
   should have “Value1” and “Value4” selected.
 * Can anyone of you please help me with this? Thank you in advance!

Viewing 1 replies (of 1 total)

 *  Plugin Author [Takayuki Miyoshi](https://wordpress.org/support/users/takayukister/)
 * (@takayukister)
 * [1 year, 5 months ago](https://wordpress.org/support/topic/checkbox-shortcode-with-multiple-default-values/#post-18226837)
 * Maybe this is not possible in any way. The shortcode implementation doesn’t expect
   array values for attributes. Instead, try [`default:get`](https://contactform7.com/getting-default-values-from-the-context/)
   with URL variables like the following:
 *     ```wp-block-code
       http://example.com/contact/?wpcf7_chkbox_products1[]=Value1&wpcf7_chkbox_products1[]=Value4
       ```
   

Viewing 1 replies (of 1 total)

The topic ‘Checkbox shortcode with multiple default values’ 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/)

## Tags

 * [shortcode](https://wordpress.org/support/topic-tag/shortcode/)

 * 1 reply
 * 2 participants
 * Last reply from: [Takayuki Miyoshi](https://wordpress.org/support/users/takayukister/)
 * Last activity: [1 year, 5 months ago](https://wordpress.org/support/topic/checkbox-shortcode-with-multiple-default-values/#post-18226837)
 * Status: not resolved