Mike XenForo developer Staff member Dec 8, 2017 #2 Code: {$xf.visitor.Profile.custom_fields.fieldName}
P pm4 Member Dec 9, 2017 #3 Hi, thank you for your answer. The issue is that I have this code in my controller $userid= 52; //for example $userFinder = $this->finder('XF:User'); $user = $userFinder ->with('Option', true) ->with('Profile', true) ->where('user_id', $userid) ->fetchOne(); $name = $user.Profile.custom_fields.name; But I get ErrorException: Use of undefined constant Profile; When I search for custom fields I have them in this format. How can I get them as an object? Thanks!
Hi, thank you for your answer. The issue is that I have this code in my controller $userid= 52; //for example $userFinder = $this->finder('XF:User'); $user = $userFinder ->with('Option', true) ->with('Profile', true) ->where('user_id', $userid) ->fetchOne(); $name = $user.Profile.custom_fields.name; But I get ErrorException: Use of undefined constant Profile; When I search for custom fields I have them in this format. How can I get them as an object? Thanks!
Mike XenForo developer Staff member Dec 12, 2017 #4 Sorry, I gave you the template syntax. It'd just be $user->Profile->custom_fields->name.