News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

loadMemberContext() not work

Started by Jotade29, March 09, 2024, 11:04:17 PM

Previous topic - Next topic

Jotade29

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!!
Quote from: Diego Andrés on August 12, 2023, 02:20:18 AMI'm afraid convincing Jotade to upgrade to SMF 2.1 will require bigger effort than your work sanitizing Unicode characters  :laugh:

live627

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.

Jotade29

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
Quote from: Diego Andrés on August 12, 2023, 02:20:18 AMI'm afraid convincing Jotade to upgrade to SMF 2.1 will require bigger effort than your work sanitizing Unicode characters  :laugh:

Arantor

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)

Advertisement: