3

When I was trying to resolve this question: How to display the user picture on the search page? I found that in the THEME_preprocess_search_result function I can't access to the user information (I use the user search functionality) the only information about the searched users that I can use is the follow:

function THEME_preprocess_search_result(&$variables) {
    dpm($variables);
}

enter image description here

I can use the username and the email, I can extract from $variables['result']['title'] the username, but I think that the best way is access directly to the uid of the searched user. The problem is that I don't know how access to this information.

So, there is another way to obtain the uid of a searched user?

EDIT: I need the info of the system users (drupal users). User is not a content type.

2

Did you try implementing hook_preprocess_search_results (notice the plural search results)?

I haven't tested recently and I'm on a mobile right now. But I'm pretty sure that hook somehow had node objects (should be user objects in your case). Collect the UIDs, run a user_load_multiple and then add the user objects to each result for profit in hook_preprocess_search_results.

Update

I'm no longer on my mobile, so I could actually test this. It turns out that the user module does not feed the results set with the user account. I don't think Drupal 7 will receive these features anymore, so you'd have to patch the core user.module to achieve that.

Here is a patch if you are interested in going down that path: https://gist.github.com/Ayesh/b1892942b053dc746fb5

  • is the same situation, there is not info about the users (drupal users). User is not a content type in my case they are the system users. – Adrian Cid Almaguer Jan 17 '16 at 19:14
  • thanks, I think that you must post the patch at drupal.org – Adrian Cid Almaguer Jan 17 '16 at 20:03
  • Can I post the patch at drupal.org? – Adrian Cid Almaguer Jan 23 '16 at 21:11
  • Sure! But I believe that odds are that this will not get into D7 core because it's too late for us to add new features. But feel free to! – AyeshK Jan 24 '16 at 0:01
  • the patch is for wich version 7.41 or 7-dev? – Adrian Cid Almaguer Feb 4 '16 at 16:00

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.