• 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 );
Viewing 1 replies (of 1 total)
  • Thread Starter Andrei Zobnin

    (@fiter)

    Solution has been found:

    UM()->fields()->update_field( 'channels', $fields['channels'], $profile_form->ID );
    UM()->fields()->globally_update_field( 'channels', $fields['channels'] );
    • This reply was modified 4 years, 7 months ago by Andrei Zobnin.
Viewing 1 replies (of 1 total)
  • The topic ‘Programmatically change a list of Choices for the Checkbox field in the forms’ is closed to new replies.