I have a custom module which has all the admin users listed. Now I want to list admin users with specific roles.
In my grid collection code it has below code which get all the users:
$collection = $this->_userFactory->create()->getCollection(); $table = $collection->getTable('authorization_role'); $collection->getSelect() ->join(['role' => $table], 'main_table.user_id=role.user_id'); $collection->addFieldToFilter('role.role_name', ['nin' => ['Administrators', 'XYZ']]); $this->setCollection($collection); parent::_prepareCollection(); return $this;
I want to show all users which do not have these 2 roles "Administrator, XYZ".
How could I make join in the collection?