Watch
GitHub Core
Show your support for Zikula! Sign up at Github account and watch the Core project!
GitHub Modules
- mesteele101 responded to »ERR (3): E_USER_ERROR: Smarty error: [in pagesvar:pagesitem2en line XXX]…« 07:01 AM
- mazdev responded to »Pages 2.5.0 and updating - Page not found« 06:41 AM
- ehdwma created topic »Hide "Register new account" and change template to 3 col« 06:27 AM
- mesteele101 responded to »Zikula 1.3.3 - Selecting a category in Pages not working« 01:29 AM
- mdee created topic »How to implement returnpage ?« 01:00 AM
- nestormateo responded to »Fillters in Clip« 24. May
- damon responded to »Can the Updated Version Check be Turned Off (Z 1.3)« 24. May
Zikula Blog
- Anatomy of Open Source Projects on Mar 07
- Continuous Review on Mar 01
- Not Invented Here on Feb 24
- How to Contribute Your Code at Github on Jan 13
- 10 Steps to Coding-Nirvana: Tips for Successful Module Writing on Nov 12
- Submitting Bug Report Tickets That Get Results on Aug 17
- Cozi Tricks #1: Syntax Highlighting on Aug 07
Login
API for showing a users group
-
- Rank: Expert
- Registered: Dec 31, 1969
- Last visit: Oct 21, 2009
- Posts: 1437
To much code to currently do this, hope its available in .8 and just as easy to show a users group as it is his/her ID -
- Rank: Legend
- Registered: Dec 11, 2002
- Last visit: Oct 21, 2009
- Posts: 11674
Mark's comment here tells you the functionality will be in .8:
http://forums.postnuke.com/index.php?name=PNphpBB2&file=viewtopic&t=39347
--
itbegins.co.uk - Zikula Consulting
birtwistle.me.uk - Personal Blog
Please read the Support Guide -
- Rank: Team Member
- Registered: Mar 18, 2002
- Last visit: Oct 21, 2009
- Posts: 6606
In fact I said it's in .760. The groups module is API compliant so exposes a number of module API's for querying and manipulating groups.
-Mark
--
Visit My homepage and Zikula themes. -
- Rank: Expert
- Registered: Dec 31, 1969
- Last visit: Oct 21, 2009
- Posts: 1437
-
- Rank: Legend
- Registered: Dec 11, 2002
- Last visit: Oct 21, 2009
- Posts: 11674
Quote
In fact I said it's in .760
oops ;)
Presumably the function returns an array of group ids rather than group names - so you couldnt echo it out.
--
itbegins.co.uk - Zikula Consulting
birtwistle.me.uk - Personal Blog
Please read the Support Guide -
- Rank: Team Member
- Registered: Mar 18, 2002
- Last visit: Oct 21, 2009
- Posts: 6606
To output a debug message where the result will be an array use print_r or var_dump.
-Mark
--
Visit My homepage and Zikula themes. -
- Rank: Expert
- Registered: Dec 31, 1969
- Last visit: Oct 21, 2009
- Posts: 1437
Would be nice to know how to use it in templates too.
For example, I would like to be able to show what groups the user is in in the member list, or using advprofile and its templates.
How would i do it to show their group name instead of just their group ID, without doing an "if" statement, etc. -
- Rank: Legend
- Registered: Dec 11, 2002
- Last visit: Oct 21, 2009
- Posts: 11674
Groups_userapi_get()
Returns an array of group name, id and member ids - if you want to find the groups of lots of users you might be better off doing it through that API...
--
itbegins.co.uk - Zikula Consulting
birtwistle.me.uk - Personal Blog
Please read the Support Guide -
- Rank: Expert
- Registered: Dec 31, 1969
- Last visit: Oct 21, 2009
- Posts: 1437
what if its just for that specific user. Sry, just trying to get some better examples as thats how I learn best. Partial code doesnt help me to much, and as its looking, it doesnt look like its really that much easier than it was before. -
- Rank: Expert
- Registered: Dec 02, 2002
- Last visit: Apr 30, 2010
- Posts: 1474
I'm guessing that you would set the $userid variable for this - ie $userid = 10; (put this before the function) you would then display the groups with a and array loop I suppose...put this after the fucntion call: print_r($usersgroups); you will then see output of what the function is returning.
-Lobos
--
-Lobos
Professional PHP Framework Services: Concept, Development and Deployment -
**unknown user**
- Registered: Mar 16, 2002
- Last visit: Oct 21, 2009
- Posts: 1097
The advProfile plugin would probably be something like this on a pn0.760 install...
Code
<?php
function advProfile_userapi_usergroups($args)
{
extract($args);
unset($args);
if (!isset($uid)) {
return false;
}
if (!pnModAPILoad('Groups', 'user')) {
return false;
}
$usergroups = array();
$usergroups = pnModAPIFunc('Groups',
'user',
'getusergroups',
array('uid' => $uid));
return $usergroups;
}
?>
The template, something like this :
Code
<!--[section name="usergroups" loop=$usergroups]-->
<!--[$usergroups[usergroups].name]--><br />
<!--[/section]-->
This is done reallllly fast and I don't have time to check it......... I'm REAAAALLLY LATE....
Cya !
-
- Rank: Expert
- Registered: Dec 31, 1969
- Last visit: Oct 21, 2009
- Posts: 1437
Thanks Chestnut, thats exactly the type of example i was looking for. I will definately try it out when i get home. Would it be possible to use that same type of logic in any module? -
- Rank: Expert
- Registered: Dec 31, 1969
- Last visit: Oct 21, 2009
- Posts: 1437
Doh, doesnt work. I added the function to the pnuserapi.php file and then the template code to user_main.tpl, still no luck -
**unknown user**
- Registered: Mar 16, 2002
- Last visit: Oct 21, 2009
- Posts: 1097
The Plugin way......
usergroups.php
advProfile_plugin_usergroups.tpl
And in the main tpl :
Code
<!--[$plugins.usergroups]-->
Still untested and not much time to test anything until later though... -
- Rank: Expert
- Registered: Dec 31, 1969
- Last visit: Oct 21, 2009
- Posts: 1437
- Moderated by:
- Support
