Get XOOPS XOOPSXOOPS FAQFAQ ForumsForums NewsNews ThemesThemes ModulesModules
Submit a Q&A Request a Q&A Open Questions

Search

Donat-O-Meter

Make donations with PayPal!
Stats
Goal: $100.00
Due Date: May 31
Gross Amount: $65.00
Net Balance: $61.80
Left to go: $38.20

Donations
studioC  ($25)May-17
Anonymous ($15)May-16
Anonymous ($25)May-4

Learn XOOPS Core

Local Support

Advertisement

XOOPS Code hosted on SourceForge

How do I...

remove www

Answer here!

Did you know ?

By the way you can enlarge smilies with Koivi, just insert them with Koivi then you can stretch them, the possibilities are endless, especially with WIWImod, have fun!<br />

More details...

Random question

What is my URL?

Answer here!

Recent Q&A List

Cumulus Tag Cloud

2 2.5 2.6 3.0 2013 Abuse AntiHarvesting AntiMalUser AntiSpam API Attack Balancing Banning Beats billige black block Blocks blue Captcha cell Christmas chronolabs Cloud content Conversion dating demo docek download Dresses editor evden eve facebook familia floor framework free Friendica herre Honeypot Human instant-zero inStyler Invoice IP IPLog jQuery JSON kantor lamps List Load log logger mobile module modules Monster MyAlbum-p newbb news online Outlet PageRank Permissions pink Plugin pollos portal Prevention profile project Protector publisher Rights rmcommon Room sale security Server site Smarty Spam stem Studio svn tag tags tdmcreate Theme themes userlog website Whitepaper XFriendica xoops Xortify ZendFramework

New Users

Registering user

# 136009

aloliveira

Welcome to XOOPS!
SmartFAQ is developed by The SmartFactory (http://www.smartfactory.ca), a division of InBox Solutions (http://www.inboxsolutions.net)

Question
How to show the groups the user belongs to in the user profile
Answer
Dear Webmaster, please replace the FAQ with the following because something is wrong in the faq display:
Here begins:
-------------------
This is for adding the groups of the user to the userinfo, so they are displayed in his/her profile.
It is nice for projects that all members (not only the admin) need to know when a member is part of a special group.

I developed this hack from a post of bluescreen, who did something similar to point 2, but for another purpose. Sorry I can't find that post.
The hack is this way:

1) in the file /language/english/user.php add this line:

// hack jordi user groups displaying
define('_US_GRUPOS','Community Status');
// end of hack jordi




2) In the file userinfo.php look where it says this:

if ( is_object($xoopsUser) && $isAdmin ) {

    
$xoopsTpl->assign('lang_editprofile'_US_EDITPROFILE);

    
$xoopsTpl->assign('lang_deleteaccount'_US_DELACCOUNT);

    
$xoopsTpl->assign('user_uid'$thisUser->getVar('uid'));

}


and add this after it:

// hack display user groups

$verGrupos $thisUser->getGroups();
$susGrupos='';
        
//group number 1 is allways admin
if ( in_array("1"$verGrupos) ) { $susGrupos 'Administrator'; }

//group 4 is a group you may have created
// remove this line if you didn't
// you can also add more lines, checking numbers from 4 to X
// for the groups you created

elseif ( in_array("4"$verGrupos) ) { $susGrupos .= 'A group you created'; }
//group 2 is the registered users. All people belong to this group if they are registered.
elseif ( in_array("2"$verGrupos) ) { $susGrupos .= 'Proud Member'; }

// this asigns values to variables in system_userinfo

$xoopsTpl->assign('lang_grupos'_US_GRUPOS);
$xoopsTpl->assign('user_grupos'$susGrupos);

// fin hack mostrar grupos


If you wonder what is group 3, I must say that group 3 is Anonymous, so they don't have user profile, so no need to care about.
If you want a group displayed regardless that the user belongs to another one, use a "if" bucle instead of "elseif" for that group.

3) Finally go to modules/system/templates/system_userinfo.html where it says:

<tr valign="top">

<
td class="head" width="25%"><{$lang_avatar}></td>
<
td align="center" class="even"><img src="<{$user_avatarurl}>" alt="Avatar" /></td>

</
tr>


And add this after it:

<!-- jordihack user groups display -->
<
tr>
<
td class="head" width="25%"><{$lang_grupos}></td>
<
td class="odd"><{$user_grupos}></td>
</
tr>
<!-- 
jordiend of hack user groups display -->



Now you got it!
You don't need to create any database or nothing, just do these 3 steps.

Jordi R. Cardona.

Requested and Answered by Jordi_rc on 2006/12/1 8:18:10 (8162 reads) 2 Comment(s) Print Q&A Send Q&A

The comments are owned by the author. We aren't responsible for their content.
Hahaha , oops. I mean the 3 lines in the beginning are just a salutation... Anyway thanks for publishing this.

Jordi
Published: 2006/12/2 13:51 • Updated: 2006/12/2 13:51
I modified this hack a bit so that it shows all groups, without you having to add an if/else for each group.

I have many groups, and I may be adding more in the future, so I don't want to have to alter the userinfo.php every time I add a new group.

It's all the same as above, except in step 2 I added this code instead:



// hack display user groups

 //checks for user's groups
   
$mygroups =& $member_handler->getGroupsByUser($thisUser->getVar('uid'), true);
   foreach (
$mygroups as $group) {
       
$gname $group->getVar('name');
        
$in_groups .= $gname.", ";
   }
$in_groups substr($in_groups0, -2); 

$xoopsTpl->assign('lang_grupos'_US_GRUPOS);
$xoopsTpl->assign('user_grupos'$in_groups);

// end hack


Also, if you try to modify the template and it doesn't work. Access the template through the Admin > System > Templates.

I used this in XOOPS 2.10.17.
Published: 2007/9/22 15:05 • Updated: 2007/9/28 10:06