Page 1 of 1

Display the number of users by group in FEU

Posted: Sun Jun 20, 2010 9:03 am
by square
HI,

I'm looking for a way to display the number of front-end users on my website.

For example, there are 320 users in my member group.

How can I proceed to display in a frontend page : "there are 320 users"

Do I need a UDT ? Or do I need some module like CGDirectory ? Or is there a trick in FEU ?

Thanks for all ideas,


Square

Re: Display the number of users by group in FEU

Posted: Sun Jun 20, 2010 12:23 pm
by Ted
Get the id of the group -- I just cheat and look at the URL when you go to edit a group in the FEU admin.

Make a UDT called "set_number_of_users".  Use this code (changing the 1 with the id of the group you want to show):

Code: Select all


if (!function_exists('MyGetModuleInstance'))
{
        function &MyGetModuleInstance($module)
        {
                global $gCms;

                if (isset($gCms->modules[$module]) &&
                        $gCms->modules[$module]['installed'] == true &&
                        $gCms->modules[$module]['active'] == true)
                {
                        return $gCms->modules[$module]['object'];
                }
                // Fix only variable references should be returned by reference
                $tmp = FALSE;
                return $tmp;
        }
}

global $gCms;

$feu = MyGetModuleInstance('FrontEndUsers');

if ($feu == null)
  return false;

//Get User
$the_count = $feu->CountUsersInGroup(1);
$smarty->assign('number_of_users', $the_count);
Then just put in the your page somewhere:

Code: Select all

{set_number_of_users}
<p>there are {$number_of_users} users</p>

Re: Display the number of users by group in FEU

Posted: Sun Jun 20, 2010 2:27 pm
by square
Thank you so MUCH !! Works great !