How can I display blocked users in a template file? I have an Entity Reference field that I'd like to use to show anonymous users any blocked or active users added to the Entity Reference field. Is that possible?

If the user is logged in and has the permission administer users, then the field shows both blocked and inactive users, but I don't want to give just anyone that permission.

I need something more fine grained or a way to override.

I've tried: template_preprocess_node(), theme_field() and template_preprocess_field(). theme_field() works as long as there's at least one active user specified in the field, but if there's only blocked users specified, then it doesn't. template_preprocess_node() doesn't allow you to modify the access directly, i.e., $variables['field_somefield']['und'][0]['access'] = true;. I'd like to avoid a View if possible as I'm defining a node template.

Is there a way to override that access attribute so that the data gets sent to theme_field() and displayed to the page?

This question is very similar... maybe the same issue:

User name on blocked user account not visible in view for anonymous users


It's kinda hacky, but I solved this problem through adjusting a few lines of code in the entity reference module. Details here: Allow blocked users in an entity reference field

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.