I have the Content Profile module installed. With this module, each user has 1 to many locations that are attached to them.

These locations are created via a content type called locs.

I have another content type called todays_spot that also has a selectable location (only one) also being dynamically created via locs.

So I'm pulling some of the todays_spot data out via a view, but I need to filter it so it only displays data if the user location(s) match.

Any suggestions, I've looked all over and can't find a thing.

  • Are you using a node reference to the locs content?
    – WestieUK
    Feb 8 '12 at 9:12
  • @Westie: yes, the content profiles, as well as todays_spot uses the same Node reference to locs.
    – kylex
    Feb 8 '12 at 16:08

See this post for a solution in Drupal 7, but the same principle applies here.

Create an argument for the related loc of todays_spot.
Choose the the right relationship (node, I think), and select 'provide default argument'
Use 'PHP Code' as your default argument

You'll need to modify the code below to match your system, but it should resemble the following:

global $user;
// the code below loads via the Profile2 module, but something similar
// will work with Content Profile, but you'll need to inspect the code
// to find a function similar to `profile2_load_by_user`
// I'd start by inspecting the $user variable with print_r or dd();
$profile = profile2_load_by_user($user->uid,'facilitator');
if (!$profile) { return ''; }
if (!isset($profile->field_location['und'])) { return ''; }
foreach ($profile->field_location['und'] as $location) {
return substr($locations,1);

Don't forget to select 'Allow Multiple Terms Per Argument' before saving your new argument.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.