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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ericclaeren created an issue. See original summary.

hass’s picture

Version: 7.x-1.x-dev » 8.x-1.x-dev
Status: Needs review » Needs work

I'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.

hass’s picture

Issue tags: +Need tests
ericclaeren’s picture

Version: 8.x-1.x-dev » 7.x-1.x-dev
Status: Needs work » Needs review

Thank 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.

hass’s picture

Version: 7.x-1.x-dev » 8.x-1.x-dev
Status: Needs review » Needs work

You 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.