Programmatically change a list of Choices for the Checkbox field in the forms
-
I have “Channels” field type of “Checkbox” with a multiple “Choices” in my Profile form.
I need to be able to change the list of “Choices” for that field programmatically.
That code do almost what I want:$fields = get_post_meta( $profile_form->ID, '_um_custom_fields', true ); $fields['channels']['options'] = array( 'Option One', 'Option Two' ); update_post_meta( $profile_form->ID, '_um_custom_fields', $fields );
That code works for all the cases, except one: I want to display that checkboxes on the custom profile tab, but I’m getting an old list of Checkboxes, instead of a new one.
If I go to the WP Admin area after execution of the code above, open “Edit field” popup, I see the new one list of “Choices”. And if I click ‘update’, I see the new one list of “Choices” on my custom tab too. So I’m guessing I need to call one more function beside ‘update_post_meta’. But which one?
That’s the code of my custom tab:
$field = UM()->builtin()->get_specific_field( 'channels' ); echo UM()->fields()->edit_field( 'channels', $field );
- The topic ‘Programmatically change a list of Choices for the Checkbox field in the forms’ is closed to new replies.