How to display users with same select list value on a custom user profile page Firstly in my site, using Profile 2. i created a 'Select list field' that allows each user to choose his/her country.

I then created a custom user profile page using views by  following these steps:

1.Create a view and add a "page" display.
2. Use "user/%" as the page path.
3. Add a contextual filter "user uid" and select "provide default value" user ID from URL.

Now i want to add a block to each users profile page that displays all users from the same country as the currently viewed user profile

I have tried adding the "Profile Country" contextual filter and selecting "provide default value" user ID from URL but no results are displayed.

Is there a way to do this?
The problem is you're relying on your contextual filter to mean 2 things:


For the page it has to be the UID.
For the block it has to be the country select value that corresponds to the UID.


If you're wanting to configure it this way, you'll need your block view to derive the profile country value from a UID. One way you could do this is to use Provide default value > Type: PHP Code options with something like this:

if ($user = user_load(arg(1))) {
  $profile = profile2_load_by_user($user);
  return $profile['my_profile_machine_name']-&gt;field_my_country_field_name[LANGUAGE_NONE][0]['value'];
}


The actual code will vary based on your Profile2 configuration.