I'm using Drupal 7.12 and Views 3.3, and I want to create a Views block to put on a page, to show the current logged in user info they added to a set of custom profile fields. I have the fields created. Views is where I run into the problem.

I was able to create a Views block that shows the contents of the profile fields, but it makes a list of: 1 block of data for each user who has entered any data in these fields, and shows it to everyone. I only want it to show the current logged in user their own data.

I found a few mentions of adding a filter for "User: Current", but I don't have this option for this block. Then I found this item here:

http://stackoverflow.com/questions/7420031/drupal-7-vews-3-usercurrent-f...

Saying that I need to first add a relationship of "Content: Author", then I can add the "User: Current" filter. I wasn't able to do this either.

So, I decided to create a new Views block and see if I could figure out why these options aren't available to me. When creating a new Views block, one of the first things you do is select what to "Show", and there is a "Content" option, and there is a "Profile" option (and several others), but there is no way to select more than one option here. In the first Views block I created before I had selected "Profile" for content to show, and this removes all options in relation to content or anything else, which is why I can't make a relationship of "Content: Author". I'm not dealing with nodes of content. When I created my second Views block to test this, I selected "Show: Content", and I was able to create the "Content: Author" relationship, and then I was able to add the "User: Current" filter. But in this Views block I have no way to display profile field info.

Here are the Filter and Relationship settings available to me on the "Profile" based Views block.

Filter options:

Profile: Date changed
- The date the profile was most recently updated.

Profile: Date created
- The date the profile was created.

Profile: Label
- The profile label.

Profile: Location (field_location_us)
- Appears in: profile2:main.

Profile: Primary Issue (field_issue_area_primary)
- Appears in: profile2:main.

Profile: Profile ID
- The unique ID of the profile.

Profile: Total Operational Budget (field_total_op_budget)
- Appears in: profile2:main.

Profile: Total Org Staff (field_total_staff)
- Appears in: profile2:main.

Profile: Total Tech Staff (field_staff_tech)
- Appears in: profile2:main.

Profile: Total Technology/IT Budget: (field_budget_tech_total)
- Appears in: profile2:main.

Profile: Type
- The profile type.

Profile: User uid
- The owner of the profile.

Add Relationships options:

Profile: Type
- The profile type.

Profile: User uid
- The owner of the profile.

That last item in both lists (Profile: User uid) seems like an obvious choice, but when I try it, from either list, my Views block shows no info at all, even though I do have information filled in. (With no filters or relationships in place I see info listed in 2 sets, for the 2 users in the system who have info in the fields.) In fact every filter and/or relationship setting I've tried so far results in an empty Views block. I'm sure there's something I'm missing.

Thanks for reading this through. Any help will be very greatly appreciated!

Comments

Status:Active» Postponed (maintainer needs more info)

You may need to file this against ... I'm going to guess this is profile2 module?

It sounds like the problem you are experiencing is with a relationship that module provides. I'll let you move this issue appropriately since I'm not 100% sure which module is providing the profile entity. When you do, please return the issue to 'active'.

Status:Postponed (maintainer needs more info)» Active

Hi there, Thanks for your help.

I am using Profile2 to create additional profile fields, and those are the fields I'm displaying in the Views block I've created. I'm going to make this issue active again here, at least briefly, to clarify with you.

If I understand you correctly, the Profile2 module is supplying the relationship options that I have available in Views for this Profile-type block. Is that right? (In other words, as it stands I have no way, no option in the available filters or relationship settings I listed above, to have it only show the logged in user their own profile info. Is that correct?)

And if so, I should change the Project field for this support request to Profile2, and ask them for help, right?

Thank you again for help!

Status:Active» Fixed

It's possible to do, so...

Add

Profile: User uid
- The owner of the profile.

Once you have added that, "user: current" should appear as filter option, that's all you seem to need.

Thank you! You were close and you led me to the answer. This is awesome.

Here is what I had to do (starting on the editing screen for my Views block):

1) Advanced (expand the section on the right)
2) Relationships [Add]
3) select "Profile: User uid" and apply
4) next screen is "Configure Relationship: Profile: User uid"
- Identifier (admin label) box was pre-filled with "User" (no change made here)
- Check the box for "Require this relationship"
- Apply (save)

5) go to "Filter criteria", and click the "Add" button
6) check the box for "User: Current"*, and click the "Apply" button at the bottom
7) next screen is "Configure filter criterion: User: Current"
- "Relationship" (drop-down box with one option): [User]
- "Is the logged in user:" (yes/no buttons): select "Yes"
- Apply (save)

8) On the main Views screen, be sure to save for this to be work live on the site.

9) It works. I now only see the info for the currently logged in user in this Views block!

* Previously, I never got this configuration quite right, because I never saw the "User: Current" option.

Thank you very much for leading me to the answer!

~Christine

Status:Fixed» Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

My problem is easier. I want to create a block of content by each user on their profile page and this is how I had done the Contextual Filters part :

Added an argument for "User: Uid."
Under "Action to take if argument is not present," I selected "Provide default argument," and select "User ID from URL" as the default argument type.
Under "When the filter value is available or a default is provided," I checked "Specify validation criteria" and selected "Basic validation" as the validator.
I selected "Hide view / Page not found (404)" from the dropdown.

Onthe Blocks page I set it to appear on all user pages (user/*).

Problem is that THE SAME BLOCK DATA appears on the profile page of all user. Anything done wrong ?

Bump

Bump

Hi, why you use context filter?

Create wiev, that shows all user in system.
Create reference to nodes user. - if you need users nodes.
Then, use filter criteria - current user.

Or,
Create wiev of all nodes,
Create reference - node -> user,
Add filter - current user.

thank you for detailing this! it was very, very helpful!
you're a life-saver!
=ck
WhoMakesMovies.com

I strongly suggest you use page manager and panels to do this.
It will allow you to identify a users profile id from the viewed page rather than the old way of using default arguments from the url.
Trust me, spend some time learning page manager and panels and you'll be amazed at what you can accomplish.

Re #4: Thanks dragonwyck (and the people who helped her, too)! Your solution worked perfectly for me! I really appreciate that you took the time to write up all the steps so clearly.