XF 2.2 Trying to identify custom user field variables

EchoRomeo

Active member
I'm trying to identify my custom user field variables for use in the widget 'display condition' field. I've used {{ dump(vars()) }} on various templates in an effort to verify that $xf.visitor.Profile.custom_fields.[fieldID] variables exist for me but am not seeing anything. Specifically, I don't appear to have "Profile" under "visitor" but I've looked across templates and am not seeing my custom user fields variables anywhere else either. The below shows part of my dump variables list for my forum view template. Is there something I'm missing? Where, specifically, are these variables located?

1707216610543.webp

Thanks!
 
The var takes the form $xf.visitor.Profile.custom_fields.field_ID .

If you dump this {{ dump($xf.visitor.Profile)}}, you will see them under _values .

1707247250047.webp
 
Thanks @Paul B! The display condition I was using for a search forum widget wasn't working, and I wasn't seeing the variables, so I thought there must be an issue with the variables, but looks like that's not the case.

I basically have a custom user field that's check boxes with 50+ choice options for U.S. states and other countries. Under my profile preferences I have 'Alabama' checked and want the Alabama widget to appear as a result, but it's still not working.

Here's my display condition code for the 'Alabama' search forum:

in_array($xf.visitor.Profile.custom_fields.UserLocationsOfInterest, ['Alabama'])

Under custom user fields in the ACP, I have 'Alabama' specified for both the value and text entries in the part of the ACP where you list your choice fields...

Is there something wrong with my array conditional that's preventing the search forum widget from appearing?


Simply looked up in_array in the PHP manual to figure this out. Correct code is:

Code:
in_array("Alabama", $xf.visitor.Profile.custom_fields.UserLocationsOfInterest)
 
Last edited:
Back
Top Bottom