Cached profile issue

Let’s say an exted profile field holds color:blue. When I’m logged in on the front-end with Login, and get the extended fields the color says blue. Perfect.

Let’s say I edited the color in the manager to red. When I refresh my front-end the color says blue. When I logout on the front-end and login again, the color says red.

My question is can I get change direct? I think It’s a cache thing but not sure. Maybe there is also a way to refresh the session or something.

In real life:
I’m creating a platform with premium content. Based on a purchase the user is redirected back to their profile page. I use the extended profile in a snippet to retrieve order information.

Kind,
Ilja

did you try to clear the MODX cache and maybe delete or rename the whole core/cache - folder after changing the user-profile?

Yes I did. No result. But that’s not really what I’m looking for.

I want to make sure that if the extended fields of a profile are changed, the user sees them after a refresh.

I think that information is stored in a session or something. so maybe I can refresh that session?

Many thanks.

could you show your code, how you get this value, please?

Yes sure.

$user = $modx->user;
$profile = $user->getOne('Profile');

if ($profile) {
    $extended = $profile->get('extended');
    $color = $extendedp['color'];

    if( $color == 'green') {
        // code
    } else {
        //code
    }

};

this should get the the extended fields directly from db.
I would think, there is no session involved.
Do you call that snippet cached or uncached?

Uncached, that’s the thing. I would thought the same.

When I log-out and back in on the front-end, the values are correct.

Can’t reproduce this issue.
When I have everything uncached and change a value in an extended field, I can see that new value
immediately after refreshing the browser.

Maybe you should simplify your setup for debugging.
You could try to print the whole extended - fields by adding print_r($extended); to your snippet

Will try it thanks.

So if you change the value in the manager->users->user extended fields, and then refresh the front-end the values have changed?

yes, they have. Tested it with your snippet-code and added print_r($extended);

1 Like

Thanks. And what are the values in the manager. Just “color” and “red”?

Maybe to limit the possible causes of your problem you could test this:
If you just put the line

return time();

in your snippet and then refresh the front-end, does the number change?
If not, then the problem isn’t at all related to the user profile.

well, which key/value - pairs doesn’t matter.
I’ve used the fieldname color and different values for testing

No idea what the mistake was but I coded it again and now I see it to. It’s working. Maybe I was using a wrong kind of JSON string.

Many thanks.

This topic was automatically closed 2 days after discussion ended and a solution was marked. New replies are no longer allowed. You can open a new topic by clicking the link icon below the original post or solution and selecting “+ New Topic”.