WordPress wpform plugin submit and get multiple checked value from checkbox

Question

I had A custom PHP template for wpForm. there is checkbox for multiples value selection as stated in my template. When I Submit, the form will trigger “add_action( ‘wpforms_process_complete’, ‘sendData’, 10, 4 );” . And I would like to check the value and modify as I need to pass to external service via json. How can I get “Checked” value?

This is my template code:

public function init() {

        // Template name
        $this->name = 'Registration';


        // Template field and settings
        $this->data = array (
     'field_id' => 14,
     'fields' => array (
        2 => array (
            'id' => '2',
            'type' => 'name',
            'label' => 'Company Name',
            'format' => 'simple',
            'required' => '1',
            'size' => 'large',
        )
        11 => array (
            'id' => '11',
            'type' => 'checkbox',
            'label' => 'Options',
            'choices' => array (
                1 => array (
                    'label' => 'delivery',
                ),
                2 => array (
                    'label' => 'walk-in',
                )
            ),
            'required' => '1',
            'choices_images_style' => 'modern',
            'input_columns' => 'inline',
        ),
    );
    }

This is my submit triggered function :

add_action( 'wpforms_process_complete', 'sendData', 10, 4 );

   function sendData( $fields, $entry, $form_data, $entry_id) {

  //The JSON data.
  $jsonData = array(
   'companyName' => $fields['2']['value']
   'option' => $fields['11']['value']

  );

   }
0
, Ah Hiang 7 months 0 Answers 97 views 0

Leave an answer