Our component has a custom usergroup that is created at installation with UsersModelGroup. We need to add specific permissions to com_content for that usergroup without effecting whatever permissions may already exist for the component.

I'm familiar with creating a full set of rules for an article or category when creating the content, and for this task, could read the asset record, then use array manipulation to add my rule, but that seems a little brute-force. Is there a better way to do this?

Current com_content ACL Rules:


Using "123" as my custom user group, I need this set of rules to be in place:

  • When you say programmatically, do you need to change does values in code? If all you need is to add this once, during install, why not use access.xml? and <access component="com_yourNameHere"> <section name="component"> <action name="core.edit.MyOwn" title="MyOwnRight" /> </section> </access>
    – Andreas
    Dec 3, 2014 at 19:51
  • @Andreas - Not sure if I understand the comment, but I'm trying to update the ACL of a core component, not my component (to control changes they can make to content within certain categories that my component installs).
    – GDP
    Dec 3, 2014 at 20:00

2 Answers 2


Pending a more elegant solution, here's my somewhat neanderthal approach that works:

// Get the Asset record for com_content 
// I'm not assuming that the row id will be the same in every Joomla installation
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('id, rules')->from($db->quoteName('#__assets'))
->where($db->quoteName('name') .'='.$db->quote('com_content'));
$asset = $db->loadObject();

$rules = new JRegistry();           // Create a new Joomla Registry
$rules->loadString($asset->rules);  // Load the Current ACL rules into the Registry
$rule_array = $rules->toArray();    // Convert to Array for easy manipulation

// Set the ACL rules for Custom Usergroup 123
$rule_array['core.delete'][123] = 0;    // My custom usergroup cannot delete Content
$rule_array['core.edit'][123] = 1;      // My custom usergroup can edit Content

// Re-load the Rules registry with the modified rules array for saving
$row = JTable::getInstance('Asset');
$row->rules = $rules->__toString(); // Save as string

Sorry, but I have no option then to post another answer. If I understand you correctly, you do install your own component, and want to add another option to com_content. So can't you just use

<access component="com_content">...</>

but as I said, New to Joomla/php I should not try to answer anything.

  • Don't know that this will work or not as the access.xml is customarily used for the component being installed, but good suggestion to try nonetheless.
    – GDP
    Dec 3, 2014 at 20:27
  • Worthy of thought, but it occurred to me that the UserGroup to which the ACL applies is created on the fly, so there's no way of knowing that, in order to include it in the XML.
    – GDP
    Dec 3, 2014 at 20:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.