3

What is the best way to have group capacity limit in joomla?

Background:

  • I have three groups "Police", "Lawyer", "Programmer".

  • Users can choose which group they would like to belong.

  • Groups have their capacity limit like "Programmer" capacity limit is 10, if 10 user assign them self to "Programmer", no more user can assign to this group because it's already reach to limit 10.

I decided to create plugin for this, first problem is how to add extra field in edit group details? enter image description here

I tried onContentPrepareForm to insert field but no luck. I guess it's because backend?

    public function onContentPrepareForm($form, $data)
{
    $app = JFactory::getApplication();
    if ($form->getName() == 'com_users.group') {
        print_r($form->getName());
        $form->loadFile(dirname(__FILE__).'/forms/form.xml');
    }
}

form.xml no problem. Using the same plugin to insert field in registration page no problem.

migrated from stackoverflow.com May 20 '14 at 20:43

This question came from our site for professional and enthusiast programmers.

2

You can take a look at all the plugin events and try hooking into one of those: http://docs.joomla.org/Plugin/Events

The idea is that you hook into one of those events and run a check on how many users are in that group.

This is how you write a plugin: http://docs.joomla.org/J2.5:Creating_a_Plugin_for_Joomla

As you can see, it is unbelievably easy

  • to make sure plugin add field in correct form, which is the group edit form? or how to detect current form is group edit form? – yasinn May 20 '14 at 1:53
  • Never mind found it. it was com_users.group – yasinn May 20 '14 at 2:20
0

For use cases like this: Need to have certain groups for members, it might be a better idea to use (or develop) a membership component.

Many of these ready-made components are designated specifically to accommodate such requirements and provide functionality similar to what you are looking for.

This way you get functionality out of the box, and you won't have to mess with the core usergroups and ACL, which are not designed exactly for such "memberships/communities" type of needs.

Relative JED searches:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy