Have my own PHP script to authenticate an XF2 user and trying to get the custom profile fields, like "country". That profile field is from a set of choices. Here is how far I've gotten:
The output of $user->Profile->custom_fields->country is something like:
"united_states_2"
which is apparently some kind of reference to the actual string in the set of choices for that custom profile field.
Exactly how do I get the actual string value (which in this case should be "United States")?
Thanks in advance for any help!
PHP:
// bootstrap framework
$dir = __DIR__;
require($dir . '/src/XF.php');
XF::start($dir);
$app = \XF::setupApp('XF\App');
$username = "someuser";
$password = "somepassword"
$ip = $app->request->getIp();
$loginService = $app->service('XF:User\Login', $username, $ip);
$user = $loginService->validate($password, $error);
echo $user->Profile->custom_fields->country;
The output of $user->Profile->custom_fields->country is something like:
"united_states_2"
which is apparently some kind of reference to the actual string in the set of choices for that custom profile field.
Exactly how do I get the actual string value (which in this case should be "United States")?
Thanks in advance for any help!