prefilled one or multiple checkboxes from usermeta

By: S. J. | Asked: 08/06/2023
ForumsCategory: General questionsprefilled one or multiple checkboxes from usermeta
S. J. asked 9 months ago
Hi together, i have an form that`s stores multiple values as usermeta.   Now i wnt too be prefiled a chackbox section with this usermeta....   Example Form1 > stores values as single or comma separated usermeta Sport1 Sport2 Sport3 Sport4 and so on....   Form2 > gets values from usermeta Sports Sport1 Sport2 Sport3 Sport4 and so on....   i`ve tryed to set the Default Value of the checkboxes in Form2 with Smarttag [usermeta key="Sports"] but it`s doesn`t work... where is my mistake ? regards Sven
4 Answers
Walter JonesWalter Jones answered 9 months ago
A little hard to follow your question, but usermeta comes from the user profile of the wordpress user.  Are you saying that your trying to bring data from 1 form into another?  Or from the users profile?
S. J. answered 9 months ago
okay sorry for my bad explanation.... i`ll try to load checkboxes with userdata usermeta values The data are stored as single value like Sport1 or multiple values  Sport1, Sport2, Sport3 and with this values i want to prechecked one or multiple Checkboxes with the [usermeta key="UserMetaKey"] but it`s not working
S. J. answered 8 months ago
any ideas ?
Frank Berger answered 2 days ago

Having looked into the problem, I can confirm that if the responses are stored in user_meta and the choices/values in the checkboxes/database contain commas, the pre-filling of fields will not work.
For example, these choices/values will work:
  --
Yes I would like to take part in the event
No I don't want to take part in the event
--
But these choices will not work:
--
Yes, I would like to take part in the event
No, I don't want to take part in the event
--
I really hope this is of use to someone, I've wasted a lot of time finding out where the bug came from.

Line breaks are not interpreted in replies to this forum, I had to insert br tag manually.

Making the Best WordPress Plugin even better - Together

Take on bigger projects with confidence knowing you have access to an entire community of Formidable Experts and Professionals who have your back when the going gets tough. You got this!
Join the community
crossarrow-right