Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8244261
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T21:47:29+00:00 2026-06-07T21:47:29+00:00

I am working on my component in joomla 2.5 and i need to create

  • 0

I am working on my component in joomla 2.5 and i need to create user groups dynamically through my code.

As i know in 2.5 joomla is using nested sets for maintaining hierarchical structure so it may affect the whole table when we insert any new entry.

Does joomla provide any function that can be directly used to create user group ?
something in which we can specify the parent group and new group will be created under it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T21:47:30+00:00Added an answer on June 7, 2026 at 9:47 pm

    I solved it myself

    In my case i need to insert the child groups just under a particular group (mentioned as $parent_id in the code below)

    // get max right from all the child under parent id
        $child_query = "SELECT max(`rgt`) FROM `#__usergroups` WHERE `id` = ".$parent_id;
    $db->setQuery($child_query);
    $max_rgt = $db->loadResult();
    
    
    // calculate left and rgt for new entry
    $new_lft = $max_rgt;
    $new_rgt = $max_rgt + 1;
    
    // update lft and rgt of all entries having lft , rgt greater than max_rgt
    $upd1 = "UPDATE `#__usergroups` SET `lft` = `lft` + 2 WHERE `lft` > ".$max_rgt;
    $upd2 = "UPDATE `#__usergroups` SET `rgt` = `rgt` + 2 WHERE `rgt` >= ".$max_rgt;
    
    
    // insert new  child
    $insert = "INSERT INTO `#__usergroups`(`parent_id`,`lft`,`rgt`,`title`) VALUES(".$matrix_parent.",".$new_lft.",".$new_rgt.",'".$title."')";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im working on a pre created joomla component which using the MVC Architecture, My
I have a custom component built for a Joomla 2.5 website. It is working
I made a component for Joomla and it's working ok with the direct url:
I'm writing my first little AJAX-enabled Joomla component. I'm using mootools. I got a
I am working on one component where I need to scale and rotate image.
I am working with a third-party COM component (i.e. do not have its code).
I have custom Joomla(v1.5) component and currently working with component's router. The problem is
I develop a custom joomla 1.5 component and it's working fine locally(wamp server ,php
I am working on a custom Joomla MVC component. My view has a form
I have auth component working greatly till I implemented a page for the user

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.