I have created a Toolset custom field for all users. This is a Checkboxes field.
How in the world do I get the values from this checkboxes field for a given user in php code?
Lets say I want to get the checkboxes values for the user with ID 1. What code do I need to write to get the selected values from the checkboxes field?
Right now, i have tried using this code (checkboxes field slug is called "udbringer-til", and i want to get values for user with ID 1):
get_user_meta(1, "udbringer-til", true);
But does not work.
Shane please, you will have to be MUCH more specific. I have NO idea where to start with that.
Please see my code. Why does that not work - and what would i have to write to make it work? I have tried to be as specific as possible.
By the way, when i used support a couple of days ago, i could chat directly with one of your colleagues. That was incredibly useful. Why cannot use the chat for support?
The function will return the contents of the my-checkboxes custom field as a comma separated string and i'm printing out that value with the echo function.
Shane, Thanks for a fast and very helpful reply. I have gotten it to work now!
However, i am not sure if i can use this solution for the use case i need it for.
Here is what i need to do.
So all users has this checkbox field, "Udbringer-til" (which means "city"), so let us call the field "city" to make it easy.
Now what i need to do is that a visitor can make a search for a city. He searches for "New york", now i need to get all posts from all users that has checked New York in the check boxes. Can you help me with how I would archive this? I am not sure i can use this types_render_field for this use case?
Are you using our Views plugin to list out the posts?
This case sounds like you will need to create a search view that will allow you to filter posts by the city, assuming that the city is also on the post itself.