Closed (fixed)
Project:
User Relationships
Version:
6.x-1.0-beta9
Component:
Miscellaneous
Priority:
Normal
Category:
Support request
Assigned:
Reporter:
Created:
17 Feb 2009 at 02:41 UTC
Updated:
7 May 2016 at 01:45 UTC
Jump to comment: Most recent
Comments
Comment #1
alex.k commentedHi, it's as simple as this:
Comment #2
alexevasion commentedAlex,
Thanks so much for the quick response. I don't mean to be a continual bother, but I still can't seem to get this to work. I'm attempting to implement this snippet in an User Relationship: RTID argument for a block view. My default argument type is User ID from URL and the action to take if the argument is not present is to Display all Values. I don't think the rest of the validator stuff seems to apply to my case, but it's also above my level of understanding. Do you know what I'm doing wrong?
Comment #3
alex.k commentedOh, I misunderstood what you were trying to do... If you have a view that just needs to be shown to users who have a relationship, it's not necessary to do anything in the view. That snippet was for the block visibility option in your block config. It sounds like you do not need anything in argument settings, as it is more of an access control restriction than a data filter. Let me know if that isn't the case :)
Comment #4
alexevasion commentedI wish it worked in the block, but I already employ another snippet to show a block listing a user's nodes on their profile:
I'm not sure if this interferes or whether I am going about this all wrong. Basically, I only want a user's friends (relations) to be able to view the block. Is there an easy recipe for this? Thanks again!
Comment #5
alexevasion commentedAny other thoughts as to what I might be doing wrong?
Comment #6
alex.k commented@alexevasion sorry this dropped off the radar. Is it still an issue? It seems that the snippet in #1 does everything including what's in #4, with a small correction:
Comment #7
rjbrown99 commentedAlex,
I'm now trying to do the same thing, and I agree this would work well for a block. How about implementing this for a view with a page display? What I'm looking for is something under Basic Settings -> Access in views that would allow me to restrict the view output to only people with a relationship of type 1. I'm definitely going for access control and not arguments of what content to show. I want to restrict the view output to only specific users with an established relationship.
Do you have a thought for this use case? Thank you.
Comment #8
alex.k commentedHmm, perhaps try adding the Global: Null argument and setting its validator to PHP code. Then the snippet acts as an access control check.
Comment #9
rjbrown99 commentedThanks very much Alex - I'll test that out and report back with findings. Assuming it works I'll post more details in case others have that same need.
Comment #10
rburgundy commentedPlease do come back and post your findings. Any additional information will be very helpful to myself and others that are learning =)
I'm trying to get this to work on a content profile page that a user creates instead of the user/uid page.
Comment #11
rjbrown99 commentedOK, my findings are that it worked well :)
My goal was to have a view that was only displayed to users that have a current relationship of "friend". In the event that the relationship did not exist, I want to show the user an intelligent message that encourages them to become friends.
To accomplish this, I took the view that I already had and created an argument. The argument is "Global: Null", Provide Default Argument, User ID from logged in User, and then a validator of PHP code. The PHP code is:
In my case, since this view requires a user argument to even be displayed I did not need the other checks. The action to take if the argument does not validate is "Display empty text".
Now I have two instances where the empty text is displayed - when the view output is actually empty or when the users are not friends. The next part was to handle this appropriately to return the correct message to the user. To accomplish this, I went over to empty text, changed the input format to PHP code, and then I inserted an if/else statement to handle that condition.
Thanks Alex K!
Comment #12
alex.k commentedAwesome, thanks for posting back! If only this could be captured in some documentation page...
Comment #13
rburgundy commentedThank you very much rjbrown99!
Comment #15
rjbrown99 commentedQuick update.
I found it annoying that my admin account was always locked out of the view results because the admin has no relationship with the user. I changed my code to this:
to solve that problem. This code snippet now restricts access to the view by relationship EXCEPT for the admin account. The admin can always see the view output.
Comment #16
coolhandlukek2 commentedsubscribe!
Sorry to be a bit dim, I have added the code to the RTID argument and set the validator to basic, but it doesnt seem to work.
Am i doing something wrong?
Thx
Comment #17
coolhandlukek2 commentedHi, scrub that! Didnt read the post properly thx
Comment #18
Crom commentedThank you. Works perfectly!
Comment #19
Anonymous (not verified) commentedIs there a Drupal 7 solution?
Comment #20
hockey2112 commentedI, too, am in need of a Drupal 7 solution. Can anyone please provide guidance on how to accomplish that?
------EDIT------
I ended up printing my views content in a Panel page and controlling access via user relationships using the options in Panels.