I'm using Profile2 to allow users to create profiles.

Users can "Like" each other's profiles using Flags.

I would like to create a view for a logged in user that shows the profiles of users she has Liked who have also Liked her profile (aka 'matches').

Thanks in advance for any help!

****UPDATE******
this has been resolved. thanks.

Comments

Drave Robber’s picture

(EDIT: lol, I'm late as always, but let it stay there - someone may find this useful)

This is actually pretty simple - the only caveat is you need to start with a view of users, not a view of profiles;

then add, one by one, the following relationships:

  • User: Profile
  • (Profile) Flags: friend (by current user)
  • Flags: User's flagged content (friend)

for the second and third of those, check 'Include only flagged content' and 'Include only users who have flagged content', respectively;

then check 'Distinct' in Other > Query settings;

et voilà!

This is an export of a view (the flag is named 'friend'; the view contains only one field - name):

$view = new view();
$view->name = 'friends2';
$view->description = '';
$view->tag = 'default';
$view->base_table = 'users';
$view->human_name = 'Friends2';
$view->core = 7;
$view->api_version = '3.0';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */

/* Display: Master */
$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['use_more_always'] = FALSE;
$handler->display->display_options['access']['type'] = 'perm';
$handler->display->display_options['access']['perm'] = 'access user profiles';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['query']['options']['distinct'] = TRUE;
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['pager']['type'] = 'full';
$handler->display->display_options['style_plugin'] = 'default';
$handler->display->display_options['row_plugin'] = 'fields';
/* Relationship: User: Profile */
$handler->display->display_options['relationships']['profile']['id'] = 'profile';
$handler->display->display_options['relationships']['profile']['table'] = 'users';
$handler->display->display_options['relationships']['profile']['field'] = 'profile';
$handler->display->display_options['relationships']['profile']['required'] = TRUE;
$handler->display->display_options['relationships']['profile']['bundle_types'] = array(
  'main' => 'main',
);
/* Relationship: Flags: friend */
$handler->display->display_options['relationships']['flag_content_rel']['id'] = 'flag_content_rel';
$handler->display->display_options['relationships']['flag_content_rel']['table'] = 'profile';
$handler->display->display_options['relationships']['flag_content_rel']['field'] = 'flag_content_rel';
$handler->display->display_options['relationships']['flag_content_rel']['relationship'] = 'profile';
$handler->display->display_options['relationships']['flag_content_rel']['flag'] = 'friend';
/* Relationship: Flags: User's flagged content */
$handler->display->display_options['relationships']['flag_user_content_rel']['id'] = 'flag_user_content_rel';
$handler->display->display_options['relationships']['flag_user_content_rel']['table'] = 'users';
$handler->display->display_options['relationships']['flag_user_content_rel']['field'] = 'flag_user_content_rel';
$handler->display->display_options['relationships']['flag_user_content_rel']['flag'] = 'friend';
/* Field: User: Name */
$handler->display->display_options['fields']['name']['id'] = 'name';
$handler->display->display_options['fields']['name']['table'] = 'users';
$handler->display->display_options['fields']['name']['field'] = 'name';
$handler->display->display_options['fields']['name']['label'] = '';
$handler->display->display_options['fields']['name']['alter']['word_boundary'] = FALSE;
$handler->display->display_options['fields']['name']['alter']['ellipsis'] = FALSE;

/* Display: Block */
$handler = $view->new_display('block', 'Block', 'block_1');