I've been attempting to figure this out for the last 2 weeks. I hope someone can help me. I'm using the User Album module, but want only a specific role to get a user album. The module is no longer in development, so I couldn't get any assistance there.
When I create another role in Drupal, it inherits the permissions of the "authenticated user", and therefore gets an album as well. So I was wondering if it was possible to change the Drupal role that is assigned to Gallery2's "registered user", from "authenticated user" to some other that I have created?
That would be one way around it, but I have yet to figure out how to accomplish that.
Many thanks in advance for any assistance
Comments
Comment #1
strawman commentedYes, This is something I've been looking into myself...I'm trying to see at what point in the module it creates the album so I can rearrange some of the code in there to be specific for the role I want to give the album to.
If someone can give some direction that would be great as I could potentially make some eventual changes to make it a more permanent feature and contribute to this rockin module...
Thanks....
Comment #2
strawman commentedSo I managed to get something going...Its not that dynamic but works...and it ain't pretty either but again...it works for now....Its really only 8 lines of code spread between 2 files. I'm sure there is another way of doing this thats cleaner but I was in a pinch and needed it like yesterday.
So this is assuming you have the user choosing his role on registration. I still need to get it to work with the user changing his role after registration.
k...I started in the user.module file...line 1240. Right where it takes the form values for the roles and sends them through the filter... and I added a foreach statement to role through the array...as it s doing that I then put an if statement in there to search for the role specific to what I wanted for having the gallery. In my case the role was "Artist". So id it found the role "Artist"..I then created a session with that role. Thats it...
On to the other file.
Now...in the "module.inc" file( located in the gallery2->modules->useralbum folder). I started on line 137 where the "switch case" starts. I found the "galleryentity:save" seemed the best place to head the gallery creation off at the pass. So within that "case" I first converted my session to a variable. then unset the session. After which I then moved down to where the "if createmode equals immediate" and added my own "if" just above that line. My "if" statement says "if variable equals artist" and then closed that "if" on parentheses before the "break". here is the full case code I used....
Thats it...when the user registers and creates a role at the same time...This should get it working that only users that chooses that specific role will get a gallery. You can change the role name obviously...that should be the only thing you would need to change. i have this working with the contributed e-commerce module "Pay per role" Works great with out it though. Just using the auto assign role module.
This is with Drupal 5.7, e-commerce module latest stable for 5.7(5.x-3.4), with auto assign module, and a few other unrelated nick nacks. If anybody uses this code and has some trouble please post back here and maybe we can get some work into it to make this a bit better...or a lot better....lol.
Like I said...I'm not totally proud of this but it works in a pinch.