I need to show the list of the content created by the currently logged-in user. How do I do this with the Views module?
2 Answers
- Create View on Content, and click "save and edit".
- Add necessary fields. Title, body, post date, etc.
- Expand the "Advanced" pane.
- Add new Contextual filter.
- Check "Content: Author uid"
- When the filter value is NOT in the URL -> Provide default value -> User ID from logged in user (if you are putting this View in profile pages, better choose "User ID from URL")
- Apply and save.
- :)
Update:
Here is a short list for Views 2:
Create a View on node as primary table.
Add necessary fields as you want.
Click Add new argument(Little plus sign under arguments pane). Check "
User: UID
" and click add.When the argument is not given, choose to use a default argument, and set it to logged in user.
Update 2:
If you want to restrict access to own content, see https://drupal.stackexchange.com/a/41899/1899
-
-
1
You can also achieve this by the following in your view:
Add Relationship "Content: Author" and check require relationship, then add a filter for "User: Current" and chose Is the logged in user.
This is probably a better option if you only want to display posts created by logged in user, as it is url independent.