Subject:*
<
Name/Email:*
<
Message Icon:*
<
Select*
<
Message:*
<



Click the Preview to see the content in action.
Options:*
<
Confirmation Code*
<
0 + 5 = ?  
Input the result from the expression
Maximum attempts you can try: 10
*
<
     

Re: $xoops_isadmin, $xoops_isuser, but $xoops_<custom group>?
by mjoel on 2013/8/18 14:06:16

Thank you mamba it works...
Re: $xoops_isadmin, $xoops_isuser, but $xoops_?
by Mamba on 2013/8/18 13:31:30

"in_group" is a function, not a variable, so you need to do something like this:

le="color: #000000"><?php if (in_group('nameofmygroup')) { echo "In Group"; } else { echo "Not in Group"; }
Re: $xoops_isadmin, $xoops_isuser, but $xoops_?
by mjoel on 2013/8/18 10:58:30

Quote:

Dave_L wrote:
This may help. I haven't tested it.

le="color: #000000"><?php /** * Check whether current user is in specified group. * * @param string $group_name Name of group * @return bool True if user is in group, otherwise false */ function in_group($group_name) { global $xoopsUser; if (!is_object($xoopsUser)) { return false; } $member_handler =& xoops_gethandler('member'); $groups =& $member_handler->getGroupsByUser($xoopsUser->getVar('uid'), true); $in_group = false; foreach ($groups as $group) { if ($group->getVar('name') == $group_name) { $in_group = true; break; } } return $in_group; }


Then you could assign a template variable:

le="color: #000000"><?php $xoopsTpl->assign('in_subscribed_group', in_group('subscribed'));


Then in the template:

le="color: #000000"><?php <{if $in_subscribed_group}> ... <{/if}>


How do i use this if Im in custom php page ?

i tried this but not working
le="color: #000000"><?php if ($in_group == 'nameofmygroup') { echo "In Group"; } else { echo "Not in Group"; }
Re: $xoops_isadmin, $xoops_isuser, but $xoops_<custom group>?
by JCash on 2012/1/19 22:01:06

Nice :)

Still works with Xoops 2.5.4 but... why it is not implemented by default ?
May be into Xoops 2.6 code ?
Re: $xoops_isadmin, $xoops_isuser, but $xoops_<custom group>?
by redheadedrod on 2010/1/20 15:18:27

It has been a while since this thread was last updated and I want to know if this method works in the latest versions as of this writing.(2.3.3, 2.4.3)

If I have this right...

In /class/template.php we look for the line...
Quote:
$this->Smarty();


And insert the following lines after...
Quote:

global $xoopsUser;
if ( is_object($xoopsUser) ) {
$this->assign( 'xoops_usergroups', $xoopsUser->getGroups() );}



then in our
theme/template

use
Quote:

<{foreach item=group from=$xoops_usergroups}>
<{if $group.groupid == 9}>
YOU CAN SEE ME GROUP 9!
<{/if}>
<{/foreach}>


Then you could use this to go through every id and adjust the theme or template.

What adjustments would need to be made to this to make it look at the group name? And I assume that the system used ID 0-2 for anonymous, registered and admin.

On my site I have 2 additional users as it is a team site and I am using the registered user as the generic fans and I also have a "player" and "moderator" groups available.

Would rather set them up as the names of the groups so if I add or change groups later this can be used.

Also looks like the function listed in the first page would work the way I want it to as well and be somewhat simpler in the long run. Has anyone tested this and make sure it works?

And as has been asked where would you put this function?

Thanks!

Who's Online

169 user(s) are online (143 user(s) are browsing Support Forums)


Members: 0


Guests: 169


more...

Donat-O-Meter

Stats
Goal: $15.00
Due Date: Jul 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $15.00
Make donations with PayPal!

Latest GitHub Commits