Plugin Development – Save multiple check boxes with WordPress settings api

The field name should be uwcc_settings[uwcc_checkbox_field_1][]transform the field into a field.

Second, if you are saved as an array, you should use in_array () along with checked () Function. But first that uwcc_checkbox_field_1 Option values ​​in a variable:

$ uwcc_checkbox_field_1 = isset ($ options['uwcc_checkbox_field_1'] )
(Array) $ options['uwcc_checkbox_field_1'] : [];

Now you call checked () like so – the 1For example, in the first line, the default value (as in ) MasterCard:

checked (in_array (& # 39; Mastercard & # 39 ;, $ uwcc_checkbox_field_1), 1)
checked (in_array (& # 39; visa & $ 39; $ uwcc_checkbox_field_1), 1)
checked (in_array (& # 39; Amex & # 39 ;, $ uwcc_checkbox_field_1), 1)

Do not forget to specify the check box values. e.g. & # 39; Mastercard & # 39; and not MasterCard,