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);
}
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.
Alternative way:
Copy the file YOUR_SITE/modules/search/search-result.tpl.php to your theme and modify the code inside with this:
<?php
//obtaining the username
$username = explode('(', $title);
$username = trim($username[0]);
//getting the user object
$user = user_load_by_name($username);
?>
References:
http://drupal.stackexchange.com/q/187055/28275
http://drupal.stackexchange.com/q/186901/28275
Comment | File | Size | Author |
---|---|---|---|
#14 | how_to_access_to_the_user_info_on_the_search_page-2662674-14.patch | 481 bytes | adriancid |
#11 | core_user_add_searched_account-2662674-6.patch | 481 bytes | moshnoi |
#9 | core_user_add_searched_account.patch | 485 bytes | Anishnirmal |
core_user_add_searched_account.patch | 481 bytes | adriancid | |
Comments
Comment #3
Anishnirmal CreditAttribution: Anishnirmal as a volunteer and at UniMity Solutions Pvt Limited commentedHi,
The patch works fine, but the automated test failed., I have recreated the patch such that it just adds the user information to the search results as a variable. Hope it helps
Comment #5
Anishnirmal CreditAttribution: Anishnirmal as a volunteer and at UniMity Solutions Pvt Limited commentedHi, automated test failed itseems., please use the patch at #5
Comment #6
Anishnirmal CreditAttribution: Anishnirmal as a volunteer and at UniMity Solutions Pvt Limited commentedComment #9
Anishnirmal CreditAttribution: Anishnirmal as a volunteer and at UniMity Solutions Pvt Limited commentedThe patch fails automated test because of problem with encoding.
Comment #11
moshnoi CreditAttribution: moshnoi commentedComment #12
moshnoi CreditAttribution: moshnoi commentedComment #14
adriancid