Hi there,
I'm trying to figure out how to reference user custom field in a child theme template.
For example, I have added a checkbox with the values 0 or 1 as a custom user field. I would like to write a if statement in PHP, if custom_user_field_xyz is 1, display content.
Please could you give me an idea as to how to do that, the documentation (https://toolset.com/documentation/customizing-sites-using-php/functions/) isn't clear. I'm a little confused with the arrays.
Thank you in advance,
Kyle
The array is used to specify the output method (raw, for example, if you do want only the value, not the wrapping HTML)
A Checkbox field, for example, is called like so in PHP:
types_render_field("checkbox-field-slug", array("output" => "raw"))
This will output the checkbox value, you can try to see what it precisely outputs either using echo (a PHP function) or error_log(print_r($variable, true)); and populate $variable first with the types_render_field() function.
However, be careful with saving 0(zero) to the database:
https://toolset.com/errata/checkboxes-that-save-0-are-interpreted-as-checked-by-views/
You cannot use that in a View later, better is to save "real" values like strings or numeric (but not 0)