Display the number of users by group in FEU

Do something cool with CMS? Show us ...
This board is for 'Answers', and the discussion of answers... Not for questions.
Post Reply
square
Forum Members
Forum Members
Posts: 51
Joined: Fri Jan 15, 2010 5:02 pm

Display the number of users by group in FEU

Post 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
Ted
Power Poster
Power Poster
Posts: 3329
Joined: Fri Jun 11, 2004 6:58 pm

Re: Display the number of users by group in FEU

Post 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>
square
Forum Members
Forum Members
Posts: 51
Joined: Fri Jan 15, 2010 5:02 pm

Re: Display the number of users by group in FEU

Post by square »

Thank you so MUCH !! Works great !
Post Reply

Return to “Tips and Tricks”