I need to use "$memprofile" for some operation in a function that gets called by "member_profile_start" hook because I want "member_profile_avatar" template to access variables in that function.
I know "$memprofile" could easily be used with "member_profile_end" hook, however, "member_profile_avatar" template cannot access to there: "member_profile_avatar" template only works with variables defined in a function triggered by "member_profile_end" hook.
Is there a way to use "$memprofile" in a function that is triggered by "member_profile_start" hook?
$memprofile is defined just before the hook is run, so if you put
global $memprofile;
in your function, you'll be able to access it.
(2021-03-12, 03:17 PM)Matt Wrote: [ -> ]$memprofile is defined just before the hook is run, so if you put
global $memprofile;
in your function, you'll be able to access it.
Tried, but doesn't work. Code is as following:
...
$plugins->add_hook('member_profile_start', 'my_plugin_function');
...
function my_plugin_function()
{
global $memprofile;
echo "<script>console.log('Debug Objects 2-1: " . $memprofile['username'] . "' );</script>";
}
And it prints out nothing.
Maybe something like
$GLOBALS['memprofile']['uid']
What version of MyBB are you on? It seems the hook used to be higher up and ran before $memprofile was defined.
(2021-03-12, 04:28 PM)Matt Wrote: [ -> ]What version of MyBB are you on? It seems the hook used to be higher up and ran before $memprofile was defined.
I confirm.
On actual version, hook is
line 2029 when memprofil is loaded between 2008 and 2020.
Was changed in 1.8.23 it seems.
(2021-03-12, 04:05 PM)Supryk Wrote: [ -> ]Maybe something like
$GLOBALS['memprofile']['uid']
This also doesn't work. I am using 1.8.22 version.
Only thing it looks working inside that my_plugin_function() function is $mybb->user. But I really need to use memprofile variable.
(2021-03-12, 04:28 PM)Matt Wrote: [ -> ]What version of MyBB are you on? It seems the hook used to be higher up and ran before $memprofile was defined.
I am using 1.8.22 version.
As-per my previous post, the hook was moved in 1.8.23 so it'll only work in that version onwards. It would be a good idea to upgrade anyway as we've fixed some security vulnerabilities in the releases since 1.8.22.
(2021-03-12, 05:51 PM)Matt Wrote: [ -> ]As-per my previous post, the hook was moved in 1.8.23 so it'll only work in that version onwards. It would be a good idea to upgrade anyway as we've fixed some security vulnerabilities in the releases since 1.8.22.
I will try upgrading and reply if works. Thank you very much!