Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi,
Realname doesn't exclude blocked users, by adding a queryTag to the select query, the realname autocomplete would be partially alterable.
I have created a patch for Drupal 7 to accomplish this. Would be really nice if this could go into realname.
Comments
Comment #2
ericclaeren CreditAttribution: ericclaeren at ezCompany commentedThe patch.
Comment #3
hass CreditAttribution: hass commentedI'm not sure how helpful this really is. I guess it will cause a lot of new issues. It may make sense to add a per field setting that removes blocked users, but not globally. If you can make this patch with per field setting I'm fine and see the possible usability benefit. Aside, I'm not sure if that tag need to be unique. Otherwise you do not know what query you may alter.
Comment #4
hass CreditAttribution: hass commentedComment #5
ericclaeren CreditAttribution: ericclaeren at ezCompany commentedThank you for your reply, I appreciate the feedback.
What kind of issues could it possibly cause?
With this queryTag you can alter the query if necessary for your specific case, You might want to join a field to check on something and makes this an small change which has less impact on this module compared to a field instance setting. I have added the field instance as meta data, so it's possible to alter the query for a specific field, entity_type or bundle.
In my case I wanted users to select a user entity reference without:
* user 1
* blocked users
I have named it specific so it wouldn't collide with an existing tag and therefore possible create issues.
A field setting would be too limited in my opinion, because it could be any property you'd want to filter on, as in my case also user 1.
My first approach was overriding the #autocomplete_path which is overridden by realname with a custom callback (due to this fact which was almost a copy of the realname's callback). I thought this would be an cleaner way to do this, with less impact.
Entityreference module which provide the default autocomplete also provide a tag: entityreference. So I don't see why this is not an easy and correct way to do this. It might benefit users wanting to use realname, but don't need the forced autocomplete widget callback or want to use it, but with some minor adjustments.
Although it might be better to call the tag: realname_autocomplete so it's unique enough not to collide with future query tags on other realname queries.
Comment #6
hass CreditAttribution: hass commentedYou need to keep in mind that disabled users may created content in past. In this case the author is no longer shown with real name. The same will happen in every other field that uses getDisplayName(). This may cause a lot of confusion. I use realname to hide the usernames. This reduces/removes the chance for automated tries to test valid logins with random passwords.
We always need to have a D8 patch first, than we may backport.