Skip Navigation

[Resolved] Multiselect User Fields

This support ticket is created 7 years, 5 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 18:00 9:00 – 18:00 9:00 – 18:00 9:00 – 18:00 9:00 – 18:00 -
- - - - - - -

Supporter timezone: Europe/Madrid (GMT+02:00)

This topic contains 3 replies, has 2 voices.

Last updated by Juan 7 years, 5 months ago.

Assisted by: Juan.

Author
Posts
#455971

Add support for Multiselect User Fields to User Forms, in the same way that you have Multiselect Generic Fields.

#457195

Juan
Supporter

Timezone: Europe/Madrid (GMT+02:00)

Hi Richard

Thanks for the feedback.

As you already know, you can create mutiselect fields as generic fields on CRED forms for both posts and users. We do not have "native" multiselect fields, because the "native" fields are the ones that Toolset, as a whole, can work with, and we do not have "native" multiselect fields in Types.

We already have a feature request about adding multiselect fields in Types, which will trigger the change in Views and CRED, but we did not aprove it yet and it is not in our current or next development cycle. This might change if the amount of requesst on this increases.

The main problem here is that multiselect fields, by their nature, hold several values at once. Storing, comparing and updating such values can be tricky, nd we do not want to face the same problems we do have with other fields storing reveral valus, like checkboxes, which mak them quite difficult to query and use in searches. But I am sure we will find a solution.

Hope this helps.

Regards.

#458917

Juan

I want to use a CRED User Form to register a user. As a part of the process I want the user to be able to select their top five skills from a defined list. I then want to pass their selections to another plugin, Ultimate Member, to display. I want to use a multiselect field to collect the choices. I don’t want to use checkboxes, as I have a long list of skills for the user to choose from.

I have created the below Generic Field which is saving and passing values to Ultimate Member, but the values are coming out as the word Array. How do I get the actual values to display?

[cred_generic_field field='top_skills' type='multiselect' class='' urlparam='']
{
"required":0,
"validate_format":0,
"default":[],
"persist":1,
"options":[
{"value":"analysis","label":"analysis"},
{"value":"management","label":"management"}
]
}
[/cred_generic_field]

Thanks,
Richard

#458969

Juan
Supporter

Timezone: Europe/Madrid (GMT+02:00)

Hi Richard

The array containing the values for a multiselect field is not just an array of values itself. If you debug the content of it, it has the following structure:

array(
    'value-one' => array(
        [0] => 'value-one'
    ),
    'value-two' => array(
        [0] => 'value-two'
    )
)

As you can see, the value is an array of arrays, being each key the array value, and eaxh subarray an indexed array with just the selected value as its value. It looks weird, I know, but it is that way for backwards compatibility issues.

If you just want to pass the values to a third party, you will need to:
* First, unserialize the field value. I think you have this already.
* Second, get just the array keys of the field value. Use array_keys() for that.

Hope it helps.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.