Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Ajay

    (@ajay)

    You can only search for posts. The plugin doesn’t allow you to find users / user profiles.

    I have integrated this functionality into the Plugin myself. It was surprisingly easy if you have a moderate knowledge of PHP and MySQL.

    Plugin Author Ajay

    (@ajay)

    @adrianlittee, would you like to share the code with other users?

    Here is what I used and forgive me if it is rough and not using WP standards but I threw it together pretty quickly for work.

    My Query is using user meta which we are importing from an active directory server so it may not me in your system. Hopefully it will be at least a start for anyone wondering how to get it working.

    //Employee Results
    echo '<div id="employee-results">';
    echo '<h1 class="page-title">';
    echo __( 'Employee Results', BSEARCH_LOCAL_NAME );
    echo '</h1>';
    
    $min = 0;
    $max = 1;
    
    //query info
    $user_tab = 'wp_usermeta';
    $user_query = "SELECT * FROM $user_tab WHERE meta_value LIKE '%$s%' AND (meta_key = 'adi_displayname' OR meta_key = 'title')";
    $user_sql = mysql_query($user_query);
    $count_emp = mysql_num_rows($user_sql);
    
    //displaying the query and employee results
    if($count_emp > $min){
    	while($user = mysql_fetch_array($user_sql)){
    		$user_id = $user['user_id'];
    		$meta_table = 'wp_usermeta';
    		$meta = get_user_meta($user_id);
    
    		$author = $meta['first_name'][$min].'-'.$meta['last_name'][$min];
    
    		echo '<div class="employee_results post-entry">';
    		echo '<h2><strong><a href="https://mydomain.com/author/'.$author.'">'.$meta['adi_displayname'][$min].'</strong></a> - '.$meta['title'][$min].'</h2>';
    		echo '<a href="https://mydomain.com/author/'.$author.'">'.get_avatar($user_id, 32).'</a>';
    		echo '</div>';
    	}
    } else {
    	echo 'There are no employee results for: '.$s;
    }
    echo '</div>';

    I inserted the code into the better-search.php page. I spit the page in two so it would display employee results on one side and better-search results on the other side. Hope this helped ??

    Plugin Author Ajay

    (@ajay)

    Thanks for sharing the code. It does make sense for users targeting employee search or similar user results.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘search by user profile and post title’ is closed to new replies.