How do I explode/sort additional usergroups please

Ingenious

Well-known member
On my basic but functional member map which is created from custom user fields for long/lat, and is a standalone PHP file and not a plugin (although is prettied up by using an embed PHP plugin), I used to have different coloured pointers on vB for different user groups, using this probably quite long winded PHP to sort the additional usergroups out (which were taken directly from the database, and where separated by commas, such as 10,12 if member of group 10 and 12):

Code:
$pieces = explode(",", $membergroupids);
 
if (in_array("10", $pieces)) {
$pointericon=", adifferentmapIcon";
$pointertext="</br><b>In usergroup 10</b>";
}
 
(and so on, for each usergroup I wanted to show)

On XenForo though, I cannot make sense of the additional usergroup data.

Someone in additional usergroup 7 has the data:

37

Someone in groups 7 and 13 has the data

372c3133

It seems to be 3 + group id + 2c3 + 3 if the group ends in 3

Groups 6, 7 and 13:

362c372c3133

Groups 6 and 7:

362c37

Any help please on how to explode/sort that so that an array contains just the usergrpoup IDs like the code above?

I had hoped I could use the xen code to check if a member "is member of" but they don't seem to work in a PHP file that is itself embedded in another which is being wrapped in the forum header and footer.

Just to be clear, I don't want to make this into a plugin etc I just want to be able to process the raw usergroup data shown above :)
 
Look at this part of code, it should help you:

Code:
            $visitor = XenForo_Visitor::getInstance();
            $visitorUserGroupIds = array_merge(array((string)$visitor['user_group_id']), (explode(',', $visitor['secondary_group_ids'])));
 
          if(isset($options->ADMINCP_OPTION))
            {
                $abcdef_ok = array_intersect($visitorUserGroupIds, $options->ADMINCP_OPTION);
            }
 
            if ($abcdef_ok)
            {
//code
            }
            else
            {
//code
            }

You can see the $visitor['user_group_id'] and $visitor['secondary_group_ids'] variables. The first one will be a string, the second one an array (the user can be in several secondary groups). You can get thoses variables thanks to this command:
XenForo_Visitor::getInstance();

Don't hesitate to use this command to display a variable:
Code:
Zend_Debug::dump($myvariable);
it's great tool to debug, better than var_dump().
 
Thanks, but I've looked at that and it doesn't help. Remember I'm running an independent script so I can't use the functions in XenForo, I can only get the raw contents of the usergroups field which is "372c3133" for example. Really I need the relevant PHP code to convert that into 7,13 in this case. The above code explodes around commas which are not in this data, that is how I did it before anyway since it is how vB stores the data.
 
Top Bottom