Hi,
here is the application case:
if one wants to make a view that lists the members who are administrators in a group, it is not yet possible because, in Views, the filter criteria "OG membership: Role" or "Group: Role" are not available.
For example in panels you can present the group manager by exposing the token "node: author", but as for one node you can only insert one author, then you cannot list all the group administrators name, as you can have only one manager.
It would be great to be able to expose the name of all administrators, hence have a filter that acts on the member's role in the group.
Thanks
Comments
Comment #1
drupalycious commentedA comment: in views, one can access "Users: Role" but it is of course related to the "drupal roles" not "OG roles".
Comment #2
MickC commentedI have a menu tab working for OG's using panels or views - however I can't control page Access based on Group Membership.
Basically I want to only show the tab if the user is a member of the group.
This WOULD work if I could create the tab in views as I could with D6 as I could set visibility based on group membership.
In D7 there's no group membership context in the Access option.
I've tried setting access to OG permissions within views but can't seem to get it to work.
OG Roles don't seem to be recognised in views either.
Comment #3
milley commented+1 subscribe
Comment #4
weekbeforenextI had this same issue. I have a couple patches and a new file I'd like to see committed that adds this feature.
As far as I can tell, it does the trick. I hope it works for everyone. Let me know if you come across any problems.
UPDATE: Looks like there are a few bugs. It works in some cases. This is important to my current project so I will continue to debug and update here. Feel free to test and let me know what you experience.
Comment #5
weekbeforenextI forgot to post one of the patch files. This one is for og_context/og_context.info.
Comment #6
weekbeforenextAttached are new patch files.
The plugin works for blocks but has problems for views in page display. I'm going to post to the views issue queue as well to see if anyone knows what the problem may be.
I updated the og_context() function so that group context information can be retrieved from a views page url, as long as the path includes 'node/%'. That would be a requirement for using the OG role access plugin for a views page display.
Comment #7
weekbeforenextI posted in the Views issue queue to see if the problem was with the way I was writing the plugin and I got a quick response. - http://drupal.org/node/1744996#comment-6381350
The problem persists, but the access callback is working now. I am working on pin pointing the problem with a debugger/profiler next.
Comment #8
weekbeforenextOkay, I have a working product for views block and page displays.
Attached are patch files based on the latest 7.x-2.0-beta1 download posted 2012-Jul-01.
I think some of this code can be resolved with the changes to the permission based access at http://drupal.org/node/1606990. I used C_Logemann's patch to get role based access working, but I see room for sharing code between our access callbacks.
(Sorry for all of the separate patch files. I'm a noob and I'm not sure how to condense them.)
Comment #10
Jackinloadup commentedHere is a reroll of everything in #8.
I haven't tested the results of this patch at all.
@weekbeforenext
Thanks for contributing
Hope this helps ^_^ Making a Drupal patch with Git
Comment #11
weekbeforenextThanks so much for taking a look. I'm a noob at making patches and I'm so glad you sent me the link. I will take a look.
Comment #12
amitaibu@weekbeforenext,
Thanks, but your patch seems to be a different use case, please submit in another issue.
Comment #13
weekbeforenextSorry about that. I have posted a patch on this issue: http://drupal.org/node/1510486.
Thanks!
Comment #14
weekbeforenextSo, I misunderstood the problem initially, but it ends up I needed this functionality, too. I have created a sandbox project called OG_Role_Access that now includes the ability to filter users by their OG Role.
The one issue I ran into was using the Views Bulk Operations, Modify OG user roles. If you need this too, I am helping to create a patch at http://drupal.org/node/1799640.
Comment #15
petednz commentedCan anyone help clarify if my issue is the same. We have a Views Content Pane to show OG members on a Groups tab.
Maybe I have my Panel settings wrong, but this page is showing to non-members.
Seems that I should be able to use the Views - Content Page - Pane Settings - Access to be able to say 'hey, if you are in this OG, then you can see this View, otherwise no luck'
But no such option seems to exist.
Thanks for your advice or pointing out the obvious if I have missed it.
Comment #16
weekbeforenextTry setting Access control for the view.
If you go to the view and select the content pane display, under Pane Settings is Access. You can set access rules based on a particular OG Permission and that should hide the view for non-members. Hope this helps.
April
Comment #17
petednz commentedhi weekbeforenext - thanks for your reply - i should have mentioned that I knew there was that option - but my testing showed that while I could set it so eg only people with specific 'group permissions/roles' would have access - this still seemed to be generic - ie anyone in any group with the specified role/permission could access the pane regardless of the group - ie it restricted it to people by role/permission but not by 'is this person actually a member of this OG' - i will take another look in case i had a blindspot
Comment #18
weekbeforenextWould it make since to modify the Page's Access settings, adding criteria that the current user must be a member of the current group? I have pages setup with the group's nid in the URL and I set access criteria to make sure that nid is a group, the current user is an active member of the group and that they have a specified role/permission in the group. This would control access to the entire page though and I'm not sure if that is what you are looking to do.
However, this doesn't seem to be related to this issue thread, so you might want to create a new issue if you still need help. This thread is looking for a solution to filtering a view of users by OG Role.
Comment #19
petednz commentedThanks again - yes I will make a new issue and see if a patch is required to make 'is member of group' one of the Access options in the View Content Pane settings.
Comment #20
petednz commentedNew issue is here in case anyone on this thread has a solution/explanation. http://drupal.org/node/1854332
Comment #21
okeefferd commentedSubscribing. This would be great as I am currently using OG groups to display service pages (and related information, article lists, etc) and I want to be able to list service admins separately from all users in that group.
Comment #22
hydra commentedI had a simular usecase, I needed to display a list of Users having a specific role in a OG. Actually this is already possible. There is a filter called "OG user roles: Role Name". You may need to apply the relationship "OG membership: OG Roles from membership" wich uses the relation "OG membership from User".
I attached an export, based on the default OG membership view, so everyone can reproduce how I got there.
Comment #23
Strutsagget commentedDosn't work for me i get validation errors.
Why do you fetch group ref as contextual filter and not uid from url?
I seem to get it to work with a node view, contextual filter uid, og membership from node, User from OG membership, Roles from membership. and a filter on active users, and a filter on "group name in my case team".
But it only works as long as i don't want to view the role with field OG user roles in group.
Comment #24
amogiz commentedReally thanx for this !!!!!! It worked for me and solved my problem.
Comment #25
joshuautley commented#22 Thank you. Relationships, relationships, relationships. I need to drive that into my head.
Worked great for me. In our use case we had some group members who didn't want to be listed in the group member view from og extras. We link to this page from a og menu and we also display the members in a block on the member page. I had initially create a role in Drupal to omit them from the list but this applied to all groups and was a burden with regard to performance. I then scrapped that and added a checkbox to the member profile for admins to check but again this was site wide and not group specific removing members from every group member list. Then though finally occurred to me to create a new role within each group and then filter on that role but until I read comment #22 I could not figure out how to obtain that "relationship" value.
If there is a better way to do this chime in. As it is now this works for our immediate needs but we can update it later if there is a better way.
Thank you again.