vanlueckn
Forum Replies Created
Viewing 1 replies (of 1 total)
-
Forum: Plugins
In reply to: [CMB2] Update CMB2 multicheck field optionsHi`Hello,
thank you very much for the answer.
I create the custom field as follows:
add_action( 'cmb2_admin_init', 'cmb2_metaboxes' ); /** * Define the metabox and field configurations. */ function cmb2_metaboxes() { /** * Initiate the metabox */ $cmb = new_cmb2_box( array( 'id' => 'vlck_syncbox', 'title' => 'Synchronisation - Einstellungen', 'object_types' => array( 'post', ), // Post type 'context' => 'normal', 'priority' => 'high', 'show_names' => true, ) ); $sites = []; $sitesOption = get_option( 'wp_api_mcs_sites' ); if ( $sitesOption ) { foreach ( $sitesOption as $url => $site ) { $sites[ $url ] = $url; } } $fieldId = $cmb->add_field( array( 'name' => 'Ziele', 'desc' => 'Ziele mit denen dieser Beitrag synchronisiert werden soll.', 'id' => 'vlck_field_sync_to', 'type' => 'multicheck', 'options' => $sites, ) ); if ( $fieldId ) { add_option( 'vlck_sync_field_id', $fieldId ); } }I then need to adjust the available options of the Custom Field in another method from time to time. For example, at the beginning I have only two check boxes in the multi-checkbox field, but later I need three or even four
Viewing 1 replies (of 1 total)