Module Description
This is small module but it will save you a big headache, especially in editorial settings. There are two places you'll be looking for entity reference users.

The first field is "authored by", found under authoring information. It's available in any content type you create. In order to see that field as a content editor, you must have the permission to "administer content".

The second place where you will need to reference users is to add a custom field in a content type as entity reference user. This field has a configuration form that asks you to fill out "reference method","filter by" and "sort by".

In Drupal core, ../core/modules/user/src/Plugin/EntityReferenceSelection/UserSelection.php this plugin provide the entity selection for the user and in order to view all users, blocked/active, you must have the permission "administer users".

if (!$this->currentUser->hasPermission('administer users')) { $query->condition('status', 1); } Why did I make this module? I want the content editors to have the ability to be able to reference all users (blocked and active) in Authored by field or in any custom entity reference user field.

There is some work available on Drupal to create a patch that gives you the ability to include the blocked users in the configuration form for the custom field. But, there is no solution for the "authored by" field, because the authored by field does not have a configuration form. https://www.drupal.org/project/drupal/issues/2756179

I wanted one solution for both scenarios (the "Authored by" and the custom entity reference user). The solution is to create a custom permission that can be assigned to any role in the system, that allows that role to reference all users (blocked and active). That's what this module does.

Testing process Login as an admin and create four users and one role
Install the module and apply the permission to editor role.

Create two entity reference user fields inside article content type. We are testing the configuration and the new permission
First field, in the configuration form we include anonymous user and all roles.


Second field, in the configuration form we exclude anonymous user and filter by editor role only.


Logout and sign in as an editor and try to add or edit article.
For Authored by field, the field will reference all users


For the first new added field, the field will reference all users

For the second new added field, the field will reference all editors



Developed By: Alaa Haddad If you have any questions or comments, please use Drupal.org for communication with me.
Project Usage
71
Creation Date
Changed Date
Security Covered
Covered By Security Advisory
Version Available
Production
Module Summary
This module aims to solve the issue of content editors not being able to reference all users (blocked and active) in the 'Authored by' field or in custom entity reference user fields by creating a custom permission that allows roles to reference all users.
Data Name
reference_blocked_users

OPENAI CHATBOT

OPENAI CHATBOT

14:30:55
Generic Chatbot
Hi, I'm a Drupal module expert powered by OpenAI, answering your questions about the Drupal module ecosystem. How can I be helpful today? Please note that we will log your question.