• Resolved molokini

    (@molokini)


    Hello,

    We have on our edit profile page a multi select field with some values derived from a callback.

    The issue we have is when a user registers, via a callback added on the um_after_save_registration_details action, we divert some of the user’s entered information into a new post in a custom post type (essentially it creates a post which has company information)

    They now want to allow the user associated with the company to edit their company’s details, which for the most part we can do with callbacks on the um_edit_{$key}_field_value action, but for multiselect fields we cannot populate the value no matter what we try, whether returning an array, a string value, nothing.

    We also tried um_field_{$key}_default_value action but this seems to do nothing.

    All we want to do is when the multiselect field renders, is have the callback populate it as now, but change the selected values according to ones we pull from the user’s company profile.

    Thanks.

Viewing 1 replies (of 1 total)
  • Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @molokini

    The following hooks are filters not action.
    um_edit_{$key}_field_value & um_field_{$key}_default_value

    Here’s how you should use it:

    add_filter( 'um_field_{$key}_default_value', 'my_field_default_value', 10, 2 );
    function my_field_default_value( $default, $data ) {
        $default = 'test swap value'; // do something
       return $default
    }
    

    Regards,

Viewing 1 replies (of 1 total)

The topic ‘Set multiselect field default values programmatically’ is closed to new replies.