Title: Set multiselect field default values programmatically
Last modified: December 13, 2019

---

# Set multiselect field default values programmatically

 *  Resolved [molokini](https://wordpress.org/support/users/molokini/)
 * (@molokini)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/set-multiselect-field-default-values-programmatically/)
 * 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](https://wordpress.org/support/users/champsupertramp/)
 * (@champsupertramp)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/set-multiselect-field-default-values-programmatically/#post-12241653)
 * Hi [@molokini](https://wordpress.org/support/users/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.

 * ![](https://ps.w.org/ultimate-member/assets/icon-256x256.png?rev=3160947)
 * [Ultimate Member – User Profile, Registration, Login, Member Directory, Content Restriction & Membership Plugin](https://wordpress.org/plugins/ultimate-member/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/ultimate-member/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/ultimate-member/)
 * [Active Topics](https://wordpress.org/support/plugin/ultimate-member/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/ultimate-member/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/ultimate-member/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [Champ Camba](https://wordpress.org/support/users/champsupertramp/)
 * Last activity: [6 years, 6 months ago](https://wordpress.org/support/topic/set-multiselect-field-default-values-programmatically/#post-12241653)
 * Status: resolved