News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Display Additional Membergroups on Profile

Started by vbgamer45, January 09, 2007, 10:16:18 PM

Previous topic - Next topic

C4G-TK

#140
running 2.0.2

I did the fix in post #139 which solved the one error that I was having.

But, I'm still getting a different which is this one:

http://www.xxxxxxxxxx.com/xxxxxxxxxx/index.php?action=profile
2: Invalid argument supplied for foreach()
File: /home/xxxxxxxxxx/public_html/xxxxxxxxxx/Themes/default/Profile.template.php
Line: 137

The error line is the foreach ($context['member']['list_additional_groups'] as $list_additional_group)


// If they are assigned to additional membergroups, show them.
$x = 1;
if (!empty($context['member']['list_additional_groups']))
    foreach ($context['member']['list_additional_groups'] as $list_additional_group)
{
echo '
<dt>', $txt['position'], ' ', $x, ': </dt>
<dd>', $list_additional_group, '</dd>';

$x++;
}


-img removed-

CreativeITWorld.com

#141
I notice that there are no current instructions for enabling this useful mod within Ultimate Profile.

SMF: Ver 2.0.2
Ultimate Profile: Ver 0.9.1
Display Additional Membergroups on Profile: Ver 1.1.2

Open ..\Themes\default\Ultimate.Profile.template.php

Find
<dd>', (!empty($context['member']['group']) ? $context['member']['group'] : $context['member']['post_group']), '</dd>

Replace
<dd>', (!empty($context['member']['group']) ? $context['member']['group'] : $context['member']['post_group']), '</dd>';

foreach ($context['member']['list_additional_groups'] as $list_additional_group)
{
echo '
<dt><strong>', $txt['position'], ': </strong></dt>
<dd>', $list_additional_group, '</dd>';
}
           
 
  echo '


The code is an adaptation of an earlier code. I also removed the Position Number code used in the earlier versions for Ultimate Profile so that it no longer numbers each Position in Ultimate Profile, which for some reason only numbered the additional membergroups as "Position 1:" and "Position 2:", while the original remained as the default "Position:".



You will still have an annoying preponderance of error notices, so make sure to include the fix kindly supplied in post 109

MoreBloodWine

#142
Would you maybe consider please adding he ability to show the additional groups on the PM & post pages ?

Obviously without the Position 2,3 etc bits so it keeps to the current look of things.

Edit: Lol, I jut realized I'm he one who originally requested this mod.

Edit 2: For some people I suspect this would be best suited as an option that can be toggled.

ex.

Show in Posts
Show in PM's
Show in Both Post & PM (Obviously this doesn't need to be an option a scheckin both previous options achieves thi sthird goal.

Edit 3: The mod as it stands doen't seem to show the main position/primary group.

All I am getting on 2.0.3 is this...

Position 1: Group Name

When it should be this...

Position 1: Owner (Primary)
Position 2: Group Name (Secondary)

It's also not showing the additional groups. Regardles of what I put myelf in all I get is Position 1, even when removing all secondaryss poition one still shows but not with what its supposed to.
Want a sig like mine for your BTCGuild stats ? Then check this out: Spend-ur-Bits


Jonesy125

If I change or remove the additional groups, the old ones still stay the same in the profile view. Is this because of the cache? Meaning it only updates once every hour?

Jonesy125

Myself and a lot of other people would really like this adapted for post views also. Any chance of that?

Prids

Hi,

The only error left in my forum is this one:

8: Undefined index: list_additional_groups

File: ...................../Sources/Load.php
Line: 1287

The lines around 1287 are below.

It appears to me that the package installation has got muddled up somehow with the Aeva Media package.

Before I break anything, could someone suggest a remedy?  I know what I think needs to be done, but an experienced advisor would be a great help!

Thanks,

Paul

SMF 2.0.5 up to date on the default theme with a number of Mods including this one and Aeva Media


1279: 'local_time' => timeformat(time() + ($profile['time_offset'] - $user_info['time_offset']) * 3600, false),
1280: //'list_additional_groups' => $profile['list_additional_groups'],
1281: // Aeva Media changes
1282: 'aeva' => array(
1283: 'total_items' => $profile['aeva_items'],
1284: 'total_comments' => $profile['aeva_comments'],
1285: ),
1286: // End Aeva Media changes
==>1287: 'list_additional_groups' => $profile['list_additional_groups'],
1288: );
1289:
1290: // First do a quick run through to make sure there is something to be shown.
1291: $memberContext[$user]['has_messenger'] = false;
1292: foreach (array('icq', 'msn', 'aim', 'yim', 'facebook', 'myspace', 'twitter', 'googleplus', 'linkedin', 'youtube', 'deviantart', 'pinterest') as $messenger)
1293: {
1294: if (!isset($context['disabled_fields'][$messenger]) && !empty($memberContext[$user][$messenger]['link']))
1295: {
1296: $memberContext[$user]['has_messenger'] = true;
1297: break;

Prids


pierrelogic

Quote from: Prids on October 17, 2013, 08:55:32 PM
Post #94 seems to be the fix.  http://www.simplemachines.org/community/index.php?topic=141200.msg3031487#msg3031487

Error free again  :)

Cheers.

I agree so far no errors after this simple modification. I had hundreds of them...now none.   ;D 

Quote from: Anthony` on April 30, 2011, 05:23:45 PM
Your probably getting that error because of this snippet,
if (!empty($new_loaded_ids) && $set === 'profile')
// Get any additional membergroups to show on their profile.
$user_profile[$new_loaded_ids[0]]['list_additional_groups'] = cache_quick_get('membergroup_list_' . $new_loaded_ids[0], 'Subs-Membergroups.php', 'cache_getMembergroupListForProfile', array($user_profile[$new_loaded_ids[0]]['additional_groups']));


When loadMemberData() is called, if the $set variable is set to something other than 'profile' $user_profile[$new_loaded_ids[0]]['list_additional_groups'] isnt set to a value. This could explain why your getting errors in places other than where this function is requesting member data other than profile (such as the memberlist).

What you can do as a quick fix is to replace,
'list_additional_groups' => $profile['list_additional_groups'],

With,
'list_additional_groups' => !empty($profile['list_additional_groups']) ? $profile['list_additional_groups'] : '',

So that if $profile (which gets its data from $user_info) didnt have anything set in the list_additional_groups element, it just sets an empty string so your not getting an error.
It's all about the ride

Vagrancy

Quote from: C4G-TK on February 12, 2012, 10:55:08 PM
running 2.0.2

I did the fix in post #139 which solved the one error that I was having.

But, I'm still getting a different which is this one:

http://www.xxxxxxxxxx.com/xxxxxxxxxx/index.php?action=profile
2: Invalid argument supplied for foreach()
File: /home/xxxxxxxxxx/public_html/xxxxxxxxxx/Themes/default/Profile.template.php
Line: 137

The error line is the foreach ($context['member']['list_additional_groups'] as $list_additional_group)


// If they are assigned to additional membergroups, show them.
$x = 1;
if (!empty($context['member']['list_additional_groups']))
    foreach ($context['member']['list_additional_groups'] as $list_additional_group)
{
echo '
<dt>', $txt['position'], ' ', $x, ': </dt>
<dd>', $list_additional_group, '</dd>';

$x++;
}



For reasons apparently pertaining to datatypes and casting, that code might error out in some cases.

Stackoverflow suggests an alternative:


// If they are assigned to additional membergroups, show them.
$x = 1;
if (is_array($context['member']['list_additional_groups']) || is_object($context['member']['list_additional_groups']))
{
foreach ($context['member']['list_additional_groups'] as $list_additional_group)
{
echo '
<dt>', $txt['position'], ' ', $x, ': </dt>
<dd>', $list_additional_group, '</dd>';

$x++;
}
}

vbgamer45

Update
Version 2.0
+Added support for SMF 2.1
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

ettore.gabrielli

There is some way to show groups and icon groups on posts?

mickjav

Just installed on test forum, while viewing members list got errors in image

Advertisement: