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.
I am having a lot of trouble with getting a View that filters out all users that the current logged in user has a relationship with.
I can filter out users I have a relationship with where I was the requester using a relationship.
I can filter out users I have a relationship with where I was the requestee using a relationship.
Is there a easy way to just filter out all users that the user currently has a relationship with (even if the logged in user was the requester or the requestee?)
Thanks!
Comments
Comment #1
YK85 CreditAttribution: YK85 commentedhello again,
I was wondering if someone would be able to give me some pointers.
I am not able to find an easy way to show all pending requests for the logged in user (requests user has sent and requests user has received) into one view page.
thank you
Comment #2
dc1258 CreditAttribution: dc1258 commentedHi!
I am going to pay for the development of a mutual friends block, friend of a friend (people you might know) feature and a feature which will show all users that a user is not friends with. The last feature you would probably be able to use! Let me know if you'd be interested in sharing the cost of it!
Comment #3
YK85 CreditAttribution: YK85 commentedAre the above listings you mention new features that need to be developed into the core User Relationships module?
If so, is there an estimated cost you are thinking of? thanks!
Comment #4
dc1258 CreditAttribution: dc1258 commentedI would much rather not discuss numbers and such on an open forum. I will email you to discuss.
Just as an FYI for everyone else, once the code is developed it will not be posted or inserted into the module. This is just so I can, hopefully, recoup the cost of development (but not to make a profit.)
Comment #5
pedrofaria CreditAttribution: pedrofaria commentedI guess this feature is solved with #866400: Views filter patch for current user issue too...
Comment #6
YK85 CreditAttribution: YK85 commentedHi pedrofaria,
I'm having trouble with this one =/
It seems like all the UR filters, once applied, removes all users who are not in the UR database (requestee/requester). So I can get users with No relationship to current user, but these users all have some kind of relationship with other users. All users without any relationship to anyone are not included.
Comment #7
pedrofaria CreditAttribution: pedrofaria commentedhmmm i agree you...
I can't figure out how to solve this one... I don't know if views can handler sql EXISTS clauses in query builder...
Comment #8
YK85 CreditAttribution: YK85 commentedI'm looking at the field "User relationships: Relationship status" which shows the current logged in user's status with the user as Pending or Approved in the column. Maybe it would be helpful to have a 'No relationship' status as well?
Next I went to the filter "User relationships: Relationship status" which also allows the options Pending or Approved. If I select 'is not Pending' then only Approved is shown, and if 'is not Approved' then only Pending is shown. With a 'No relationship' status, if 'is not Pending' filter and 'is not Approved' filter is selected then 'No relationship' can be shown.
So I guess this is a feature request =)
Comment #9
rafinskipg CreditAttribution: rafinskipg commented+1 to this feature. I really need it. I can' do it making two filters for 'is not Pending' and 'is not Approved' , and make it work.
I only want to show my non-friends users, so I'll could add them to my friends list.
Comment #10
NathanM CreditAttribution: NathanM commented+2 Subscribing.
Comment #11
capellicI also spent quite a bit of time trying to do this through Views UI, but with no luck. I resorted to building a module which uses hook_views_query_alter to alter the query before it's run. Here's the cod that I used:
You should also consider putting some help text in the Views UI for any view you override like this. You can do it by adding the following function to the same module.
Reference:
http://api.freestylesystems.co.uk/api/drupal/contributions--views--docs-...
Comment #12
konrad1811 CreditAttribution: konrad1811 commentedI just tried this today but no luck :/
I use UR both with OG and have a list of OG members that a user can have relationship [Chat relationship] so that they can chat - have instant online talk...
Comment #13
konrad1811 CreditAttribution: konrad1811 commentedActually I think this could be possible using Action block modification - but I'm not specialist to do that.
I think easiest way is to pass user list [ some view] to some kind of code like Relationship Action and create "invite relationship" links for each who yet does not have such relationship with current user.
I use OG and would like to pass members ID.
Comment #14
diego.pasc CreditAttribution: diego.pasc commentedsubscribing
Comment #15
mrf CreditAttribution: mrf commentedPlease have a look at User Relationship Locator.
My aim there is to provide a relevant list of people you may know on the site that you don't currently have a relationship with, and I think that would answer the need here.
If I'm missing something about the use case behind this particular request please just set the status back, and provide what exactly needs to be changed about our current views integration to make this possible.
Comment #16
diego.pasc CreditAttribution: diego.pasc commentedHi mrf
sounds interesting.
Is it only for Drupal 7? No Drupal6 version?
Comment #17
mrf CreditAttribution: mrf commentedNo D6 version, but there is already an issue open discussing that #1399710: please provide ver 6!
Comment #18
mrf CreditAttribution: mrf commentedIf you just want to provide a list of everyone you don't have a relationship with without any further filtering or ranking (warning this query may crash your site on larger user lists) try this query.
SELECT users.uid, users.name, ur.rtid from users LEFT OUTER JOIN user_relationships AS ur ON (users.uid = ur.requestee_id AND ur.requester_id = 1) WHERE ur.rtid IS NULL;
Replace ur.requester_id = 1 with the uid you are interested in.
Comment #19
diego.pasc CreditAttribution: diego.pasc commentedThanks mrf,
I was already aware of that query.... but your module sounds smarter. In any case thanks for your effort :)
Anyway, we are going a bit off thread here.