Skip Navigation

[Resolved] user fields problem

This support ticket is created 3 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 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 4 replies, has 2 voices.

Last updated by jozsefG 3 years, 4 months ago.

Assisted by: Shane.

Author
Posts
#2082641

Hello
I'm creting a user registration form and I created some user fields with types. One of the fields is Country (Romania and Hungary in the select list) and I created County. I need to have a separeate county list for each country. I thought that I could make County a text field and I created the two county lists as generic select form fields and added the counties manually. I used conditional to show the coresponding static county list.

[cred_show_group if="( $(country) eq '1' )" mode="none"]
	<div class="form-group">
	<label for="%%FORM_ID%%_county">[cred_i18n name='county-label']Județ[/cred_i18n]</label>
	[cred_generic_field type='select' field='county']
{
"required":1,
"default":"Bihor",
"options":[{"value":"Alba","label":"Alba"},{"value":"Arad","label":"Arad"},{"value":"Argeș","label":"Argeș"},{"value":"Bacău","label":"Bacău"},{"value":"Bihor","label":"Bihor"},{"value":"Bistrița-Năsăud","label":"Bistrița-Năsăud"},{"value":"Botoșani","label":"Botoșani"},{"value":"Brașov","label":"Brașov"},{"value":"Brăila","label":"Brăila"},{"value":"Buzău","label":"Buzău"},{"value":"Caraș-Severin","label":"Caraș-Severin"},{"value":"Călărași","label":"Călărași"},{"value":"Cluj","label":"Cluj"},{"value":"Constanța","label":"Constanța"},{"value":"Covasna","label":"Covasna"},{"value":"Dâmbovița","label":"Dâmbovița"},{"value":"Dolj","label":"Dolj"},{"value":"Galați","label":"Galați"},{"value":"Giurgiu","label":"Giurgiu"},{"value":"Gorj","label":"Gorj"},{"value":"Harghita","label":"Harghita"},{"value":"Hunedoara","label":"Hunedoara"},{"value":"Ialomița","label":"Ialomița"},{"value":"Iași","label":"Iași"},{"value":"Ilfov","label":"Ilfov"},{"value":"Maramureș","label":"Maramureș"},{"value":"Mehedinți","label":"Mehedinți"},{"value":"Mureș","label":"Mureș"},{"value":"Neamț","label":"Neamț"},{"value":"Olt","label":"Olt"},{"value":"Prahova","label":"Prahova"},{"value":"Satu Mare","label":"Satu Mare"},{"value":"Sălaj","label":"Sălaj"},{"value":"Sibiu","label":"Sibiu"},{"value":"Suceava","label":"Suceava"},{"value":"Teleorman","label":"Teleorman"},{"value":"Timiș","label":"Timiș"},{"value":"Tulcea","label":"Tulcea"},{"value":"Vaslui","label":"Vaslui"},{"value":"Vâlcea","label":"Vâlcea"},{"value":"Vrancea","label":"Vrancea"},{"value":"București","label":"București"}]
}
[/cred_generic_field]
	</div>
[/cred_show_group]
[cred_show_group if="( $(country) eq '2' )" mode="none"]
	<div class="form-group">
	<label for="%%FORM_ID%%_">[cred_i18n name='-label']Județ[/cred_i18n]</label>
	[cred_generic_field type='select' field='county']
{
"required":1,
"default":"Hajdú-Bihar",
"options":[{"value":"Bács-Kiskun","label":"Bács-Kiskun"},{"value":"Baranya","label":"Baranya"},{"value":"Békés","label":"Békés"},{"value":"Borsod-Abaúj-Zemplén","label":"Borsod-Abaúj-Zemplén"},{"value":"Csongrád-Csanád","label":"Csongrád-Csanád"},{"value":"Fejér","label":"Fejér"},{"value":"Győr-Moson-Sopron","label":"Győr-Moson-Sopron"},{"value":"Hajdú-Bihar","label":"Hajdú-Bihar"},{"value":"Heves","label":"Heves"},{"value":"Jász-Nagykun-Szolnok","label":"Jász-Nagykun-Szolnok"},{"value":"Komárom-Esztergom","label":"Komárom-Esztergom"},{"value":"Nógrád","label":"Nógrád"},{"value":"Pest","label":"Pest"},{"value":"Somogy","label":"Somogy"},{"value":"Szabolcs-Szatmár-Bereg","label":"Szabolcs-Szatmár-Bereg"},{"value":"Tolna","label":"Tolna"},{"value":"Vas","label":"Vas"},{"value":"Veszprém","label":"Veszprém"},{"value":"Zala","label":"Zala"},{"value":"Budapest","label":"Budapest"}]
}
[/cred_generic_field]

The user is created but nothing is saved in the County field. How can I achieve what I want? I don't really need automatic cascading population of the second select field, I have only these two countries. I thought that this could be achieved by what I did with two generic selects.

#2083625

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Jozef,

Thank you for getting in touch.

Were there any corresponding fields on that were created as custom user meta fields ?

If so then the field names for the select should have the wpcf- prefix attached to it so that they can populate the correct Types single line fields that were created.

Please let me know if this helps.
Thanks,
Shane

#2084215

Hello Shane
Yes, I ended up tomorow finding some more information about generic fields on the and I realized that I forgot that I always have to add the wpcf- prefix. I also found that I should use "persist":1 so that the data should be saved to the database. There were some post where it was stated that the "persist" is deprecated. Should I use it or would that work without persist too?

#2084705

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Jozsef,

I believe it is still required to ensure that the value is stored in the database.

So I would recommend to manually put the persist: 1

Thanks,
Shane

#2087801

My issue is resolved now. Thank you!