Quantcast
Channel: Joomla! Forum - community, help and support
Viewing all articles
Browse latest Browse all 1690

Joomla! 5.x Coding • Re: How to create User Group Progamatically

$
0
0
Welcome to Joomla forum!

In Joomla 5 you can probably create a new User Group with something like the code below:

Code:

use Joomla\CMS\Factory;use Joomla\Component\Users\Administrator\Model\GroupModel;$group = [    'id' => 0,     'title' => 'Your new User Group Name',     'parent_id' => 1];Factory::getApplication()->bootComponent('com_users');$model = new GroupModel;if (!$model->save($group)) {    Factory::getApplication()->enqueueMessage($model->getError(), 'error');    return false;}

Statistics: Posted by pe7er — Sun Mar 24, 2024 4:27 pm



Viewing all articles
Browse latest Browse all 1690

Trending Articles





<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>