Script passing variables to another php script

pattycake2

Active member
I have this script to pass variables to another php script

Code:
$dir = __DIR__;
require ($dir . '/src/XF.php');

\XF::start($dir);
$app = \XF::setupApp('XF\Pub\App');
$app->start();
$visitor = \XF::visitor();

$da_visitor_id=$visitor->user_id;
$da_username=$visitor->username;
$da_userid=$visitor->user_id;
$da_email=$visitor->email;
$da_trackname=$visitor->location;

Everything works except the last item - location... all other variables get passed except the location - location is always blank and, the location is definitely set in the users profile but, I cannot get this one item to display.

Also wanted to get custom field called "trackname" and unable to get that even though it's set in the users profile.
Help please
 
I am not in my office and on a tablet.

Can you dump $visitor and post the output.
 
location is not a property of the User entity

Is that a problem :) ?

Well fooey.. I guess that would be the problem.

Is there another way of grabbing one of those fields? Like maybe one of the custom fields? Any of them?
 
location is not a property of the User entity.

PHP:
$visitor->Profile->location

Is this not accurate or, is this maybe for xf 1.x?
Code:
XenForo_Visitor Object
(
    [_user:protected] => Array
        (
            [user_id] => 1
            [username] => Admin
            [email] => email@domain.com
            [gender] => 
            [custom_title] => 
            [language_id] => 1
            [style_id] => 0
            [timezone] => Europe/London
            [visible] => 1
            [user_group_id] => 2
            [secondary_group_ids] => 3,4
            [display_style_group_id] => 3
            [permission_combination_id] => 7
            [message_count] => 2
            [conversations_unread] => 0
            [register_date] => 1286324538
            [last_activity] => 1286362240
            [trophy_points] => 1
            [alerts_unread] => 0
            [avatar_date] => 0
            [avatar_width] => 0
            [avatar_height] => 0
            [gravatar] => 
            [user_state] => valid
            [is_moderator] => 1
            [is_admin] => 1
            [is_banned] => 0
            [like_count] => 0
            [dob_day] => 0
            [dob_month] => 0
            [dob_year] => 0
            [status] => 
            [status_date] => 0
            [status_profile_post_id] => 0
            [signature] => 
            [homepage] => 
            [location] => 
            [occupation] => 
            [following] => 
            [identities] =>
 
Crap.... how in the world did I miss your answer?
Code:
$visitor->Profile->location

That works great...

So sorry I kept asking for help when you already threw me the lifeline and I didn't see it. Today was chemo day and when that happens, my brain gets a little foggy for at least a day or two

btw: Your answer also led me to learn how to pass custom fields data with:
Code:
$visitor->Profile->custom_fields[track]

I had just stumbled on to the answer by clicking something, (for example: account details) and then looking at the source to see the code for what variable was being used. Dunno why I never looked there first before asking. Like I said... chemo days are "difficult"

Thank you.
 
Last edited:
Top Bottom