Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Topic started by: Jotade29 on March 09, 2024, 11:04:17 PM

Title: loadMemberContext() not work
Post by: Jotade29 on March 09, 2024, 11:04:17 PM
V: 2.0.19
Hello, ii have a new doubt. I intend to load all the user information, that is, what is shown in $profile in the load.php function, for this i have the following:

$id_u = $context['user']['id'];
loadMemberContext($id_u);
$context['member'] = $memberContext[$id_u];

Yes, i use $context and $memberContext like global variable.

Where is the wrong?

Thnx!!
Title: Re: loadMemberContext() not work
Post by: live627 on March 10, 2024, 12:16:43 AM
Did you declare those as globals?

Can you post the code to help us identify the problem? A snippet of three lines doesn't tell us much.

EDIT: You're missing loadMemberData($id_u). There might be a related error in the php error log file stating such.
Title: Re: loadMemberContext() not work
Post by: Jotade29 on March 10, 2024, 03:55:02 PM
Quote from: live627 on March 10, 2024, 12:16:43 AMDid you declare those as globals?

Can you post the code to help us identify the problem? A snippet of three lines doesn't tell us much.

EDIT: You're missing loadMemberData($id_u). There might be a related error in the php error log file stating such.

Hello, thank you very much for responding, Live!! So do I have to ALWAYS use loadmembercontext() and loadmemberdata() together for it to work? I have tried and adding loadmemberdata() works for me.

And finally, loadmemberdata() use the global variable $memberContext or $user_info? Thnxx
Title: Re: loadMemberContext() not work
Post by: Arantor on March 10, 2024, 04:27:59 PM
loadMemberData must always come first, and it doesn't use either of those two things. It uses $user_profile however not in a particularly nice way, which is why you use loadMemberContext to move it to $memberContext.

You are not supposed to use $user_profile directly without understanding what state it is in (which is primarily for how the profile area updates data when you're not the current user whose data is being updated)