Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Aiheen aloitti: madzilla - tammikuu 27, 2014, 03:01:23 IP

Otsikko: Add data to $message['member']
Kirjoitti: madzilla - tammikuu 27, 2014, 03:01:23 IP
Hello all,

I need to add another variable to the $message['member'] array. This will either be a 0 or 1 based on a query to another table to check for a custom status for each user. Could someone point me in the right direction as to where I can find it? I can't seem to locate where the array is being populated.

Thanks!
Otsikko: Re: Add data to $message['member']
Kirjoitti: Arantor - tammikuu 27, 2014, 03:22:36 IP
It's populated by $memberContext, which in turn is populated by loadMemberContext() in Load.php, which in turn itself is populated by loadMemberData() also in Load.php.

Changing it is not a good idea without a serious amount of due care and caution. What do you need to add?
Otsikko: Re: Add data to $message['member']
Kirjoitti: madzilla - tammikuu 27, 2014, 03:27:42 IP
We've got a feature that allows users to donate the site for certain perks and are looking for a way to highlight these users.  That data is stored in a non-SFM table.

Another option would be to add them to a new membergroup. I'm thinking that this may be a better approach as I could simply customize the template and not make any core SMF modifications. Thoughts?
Otsikko: Re: Add data to $message['member']
Kirjoitti: Arantor - tammikuu 27, 2014, 03:35:42 IP
That would certainly be easier... or even use paid subscriptions to automate it ;)
Otsikko: Re: Add data to $message['member']
Kirjoitti: madzilla - tammikuu 27, 2014, 07:57:37 IP
Quick follow up...

I've created our new membergroup and have updated the template to show our "flair" for these users. This is working well for normal users but I also have a few Administrators who need to be in this usergroup. When I add the new group as an additional group, I don't see any mention of it in the $message['member'] array. Only Primary group is listed there. Any suggestions on how to handle this?
Otsikko: Re: Add data to $message['member']
Kirjoitti: Arantor - tammikuu 27, 2014, 08:02:05 IP
Additional groups do not get loaded for the topic display, there's no reason for them to be because there's no ability to display them anyway.

And it's not a simple table join because additional groups are stored as a text column in the members table with commas between the groups which can't be converted to a table join >_<
Otsikko: Re: Add data to $message['member']
Kirjoitti: margarett - tammikuu 29, 2014, 05:22:37 AP
Although there are MODs to do that, currently none in our modsite IIRC.
https://github.com/MissAllSunday/showCustomMembergroups
(and probably others out there)