Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
This module provides a default view, "My bookmarks". But it might be that you want to allow users to see other users' bookmarks.
If you want to setup a "user/%/bookmarks" tab on each user's profile page, these instructions are for you:
- Start a new view. (Make it a node-type view if you're flagging nodes; a user-type view if you're flagging users, etc.)
- As usual, pick a name, and possibly a description, for your view.
- Add a Page display.
- You may wish to style your view as a Table. Add the Node: Title field.
- Our tab needs a URL. Type
user/%/bookmarks
in the Path setting (You can replace the "bookmarks" word with whatever you wish). - In the Menu setting choose "Menu tab" and type a short label into the Title
- Add the desired "Flags: Node flag" relationship (if you're flagging users, or comment, adjust accordingly). In this relationship settings form, choose by "Any user" to show all the flagged nodes (we'll filter them when we add the Argument).
- Add the "Flags: User" relationship.
- Add the "User: Uid" argument. In its "Relationship:" dropdown pick the "Flag user" relationship.
- You may want to type
Bookmarks for %1
into the argument's Title box.
You're done.
Some refinements:
- You may want to type "This user hasn't bookmarked anything." into the Empty Text box.
- You may want to add the "Flags: Flagged time" field and let the user click-sort the table by it as well.
Comments
Nice feature, but not privacy safe!
Hi, This is a nice feature for users but the problem is that it's not safe! Any user can now see the flagged content by any other user simply by filling in the correct UID.
To make sure users can't see each others bookmarks (or e.g. products in wishlist) do the following:
- add a second argument: User ID
- set the relation for this argument to "Flag user"
- set as "Action to take if argument is not present:" "Provide default argument". Argument type: "User ID from logged in User"
- Set as validator "Custom PHP code"
- add the following PHP:
This is checking whether the UID of the current user is matching the UID in the URL of the page!
I believe the intention of
I believe the intention of this page is to make a users' bookmarks public, similar to the list of a users' "Likes" on Facebook.
In that case it is indeed
In that case it is indeed good as it is. In my case I'm using the flag module for costumers to create a personal wishlist of products in a webshop. This list needs to be private.
Anyway, now developers have the choice to create a private bookmarks list or a public one!
How do you set that
How do you set that relationship. When i do exactly what is described in this handbook and then additionally add your code concept. I can not select an relationship when i set the second argument User ID. There is no relationships dropdown list.
...
@garbo: I believe your little recipe is convoluted. To make only the current user's tab accessible, go to the existing "User: Uid" argument, and into a "PHP Code" validator type "
return $argument == $GLOBALS['user']->uid;"
. It works for me.(People, please help maintain this page: if you can validate that this indeed works, add this information to the HowTo and then ask the webmaster to delete all these comments.)
I changed the howto without
I changed the howto without testing, since you stated it worked for you. But now im working with it and it doesnt work...
Thanks for the help
I had deleted the default "bookmarks" flag by accident and have been looking for a way to replace it using views.
I used the PHP code posted by mooffie. I also added Action to take if argument is not present: Hide view / Page not found (404). The tutorial works and i have tested it on my live site.
want to create flagged user list from users for specific role.
I have set the flag link on user-profile and give right to company1 role to flag any user.
Now I want to create tab and list of flagged users by current user.
I tried to create list using views but not getting success.
is that possible using views?
Pragna J Bhalsod
Solved flagged users list using content profile
Hello all,
I have solved flagged users list using content profile module.
Thank you,
Pragna J Bhalsod
This worked for me
To make this a step by step for Drupal 6.x version, once editing the view, do the following:
1. Click on the argument "(bookmarks_user) User: Uid"
2. Change validator option to "PHP code"
3. Enter
return $argument == $GLOBALS['user']->uid;
into the code area4. Click "update"
5. Click "save"
Thanks!
@garbo Hey thanks that worked like a charm for me.
Similar for Drupal 7 Flags / Views 3.x
The process is somewhat similar for Views 3.x / Flag for Drupal 7:
See: #1191228: Display Nodes Flagged by a Given User (rather than current user) in a View.
__________________
Personal site: www.jeffgeerling.com
Is there something you do
Is there something you do differently in the menu tab section for Drupal 7/ Views 3 too?
Thanks for this. It totally
Thanks for this. It totally works, but I just want to emphasize how important it is to set the relationship in the contextual filter (and how easy it is to miss!!) I lost a few minutes trying to figure out why this didn't work when all I had to do was set the relationship.
https://skitch.com/drnikki/ggw1g/flagging-user
Views 3?
How do you create the menu tab with views 3?
The page settings -> menu has changed since views 2. I clicked default menu tab -> menu tab (under parent menu item), but the new tab still doesn't appear on the user profile page.
Can someone please help?
Make sure your view page path
Make sure your view page path is: /user/%/bookmarks
Type: Menu Tab
Title: Something like 'My Bookmarks'
Make sure 'Context' is un-ticked
----
Sudo Kill Cylons
New Bookmarks module for D8/9/10
The Bookmarks module is now updated to work on Drupal 8+ and it provides a tab for each User to view their list of favorites: https://www.drupal.org/project/bookmarks