You cannot query users by taxonomy. You will need to rethink your system. What would I do?
- Keep the taxonomies but use these only to output choosable values – wp_dropdown_categories()
- Save the selected value AS user meta, NOT AS taxonomies – update_user_meta()
- Now you can query users by that value – WP_User_Query()
Example:
This code would go to the page template where your jobs are posted.
// This will check if form was submitted, it will not trigger/show on "normal" page load
if( $_SERVER['REQUEST_METHOD'] == 'POST' ) {
// This will get the profession from input after form is submitted & page reloaded
// Change "profession" to the name of that input where user can choose profession
$submitted_profession = $_POST['profession'];
// Arguments for user query, see more from the user query link above
$args = array(
// How many to return?
'number' => 3,
// User meta
'meta_query' => array(
array(
'key' => 'profession', // Name of user meta key in database
'value' => $submitted_profession, // We get this from form, see above
'compare' => '='
)
)
);
// Query itself
$suggested_users_query = new WP_User_Query( $args );
// Get the results
$users = $suggested_users_query->get_results();
// Check if there actually are users based on that criteria
if ( ! empty( $users ) ) {
// All the output how you want your users to look like goes here
// I wrote a small example
echo '<ul>';
// Loop trough each user
foreach ( $users as $user ) {
// Get all the user data
// To find all the fields you could use, search "get_userdata()" online
$user_info = get_userdata( $user->ID );
echo '<li>' . $user_info->first_name.' ' . $user_info->last_name . '</li>';
}
echo '</ul>';
}
// No users with that profession
else {
echo 'No users with profession ' . $submitted_profession;
}
}