By sprite64 on
I have two different user roles: Authenticated User (can only comment on & rate content) and Artists (can create content). I've created the following profile fields: Genre, Bio, Website, Record Label, AIM Screenname. Is there a way to limit the fields Genre, Bio, and Record Label to only those users who have the Band role?
I apologize if this is a common question. I've experimented w/ all the user-related modules and have exhausted my patience searching the forums (although it's possible I simply don't know the proper jargon to use in my queries).
Thanks in advance!
Comments
I'm having the same problem.
I'm currently having to write a custom module to do this. I've got some stuff working, other stuff not. Unfortunately, it's all hard-coded right now, so isn't easily configurable. Also, I'm not sure it's the right approach. Seems like there should be an easier way, particularly as it seems like a basic requirement for a lot of sites to me.
If I find a way, I'll post it to this thread. Someday, if there's not an existing way that I haven't yet learned about, maybe I'll even make the module I'm working on more user-configurable, and post it here. But that probably wouldn't be for another month or two.
- Aaron
Culture Fix Web Identity & Design
Digital Folk Art (my blog)
same issue... dirty hack.
I found the same issue, and I find tones of snippets about how to make up the output, but nothing about how to disable profile's categories based on roles, so I made a very dirty hack to profile.module.
Sorry in advance to the original author of the module to abuse his/her code.
To make it run, replace profile_categories() function by this:
An then change the $role_disabled array to fit your needs.
At this momment I didn't find time to integrate with drupal role access or taxonomy_access... but if you are as desesperate as me, it will make the job.
Cheers,
Marc Bria
Profile Category li element returns blank
Hi Marc,
This works great but empty <li > and link elements are returned where the disabled category is meant to be. Any way to remove that?
Nice hack. This is useful code should be part of Drupal core. I believe it's in the planning for the next release where profiles will become nodes with a more configurable category system.
does it happens with other themes?
Hi,
Thanks. I agree that something similar need to be included in profiles... but my coding isn't good enough to be in core. :-)
Did your empty LI tags appear on every theme? I'm unsure, but probably is a theme issue, as far as my hack don't include lists.
CSS fix
Yes it happens with other themes. An empty
appears in secondary tabs. It was fixed using css. Secondary tabs borders and bg was removed and displayed as plain text with a mouse over bg highlight. It works perfectly.
I guess for now we have to wait for some Drupal expert to come up with a solution allowing users to select a role on signup (with multi-select functionality) and have profile categories displayed according to their role selection. This will be very useful.
Lets say we have producers and buyers as 2 role types. It would be cool to have the ability to assign profile categories that are buyer related and producer related or both.
Exception for Authenticated User? How?
Marc:
Once people register on my site, I manually upgrade them to the role "Approved Blogger". I would like to only display the field category "Blog Details" for the approved bloggers, and not the "Authenticated Users". They are only allowed to comment, not blog.
The problem with using your code to hide Blog Details is that all Approved Bloggers are also, by default, Authenticated Users.
Do you see a way to allow the Blog Details fields to only show up for the Approved Bloggers?
Just change to fit your case...
I don't know if I really understand you, but... did you try changing the "role name" by the "authenticated users" role?
If I understood you, something like this should work:
//Change this to fit your roles and categories:
$role_disabled = array (
array("Authenticated User", "Blog Details"),
array("Student", "research")
);
Hope this helps,
m.
Here's how I did it
I modifed mbria's code to enable tabs for specified roles, rather than disable tabs. This made much more sense for my application and it eliminates the problem with "authenticated user".
Drupal 6?
Anyone have something like this for Drupal 6? Or just instructions on how to do integrate this change into Drupal 6. It would be very useful.
Thanks.
Hiding fields on Edit tab and not whole tab on Profile
So as the title says I only want to hide two fields on the edit tab, or just make them non-editable, if possible, based on role.
The fields are username and mail. I would like these fields to be displayed to the users but only editable by our administration roles.
Does anyone have a code snippet or a modeul hack to do this in the profiles module? I haven't been able to get anything to work thus far.
Thank you.
PoisedGuru
Xomba.com
"Show and Tell Has Never Been So Rewarding..."
User Read-Only Module
The User Read-Only Module works great for what you need. http://drupal.org/node/53103
That's brilliant!
Thank you, that's brilliant!
PoisedGuru
Xomba.com
"Show and Tell Has Never Been So Rewarding..."
Drupal 5
Is there any new solution for Drupal 5, much cleaner ?
Thank you.
Restrict Username cahnges in Drupal 5.1
I believe you can restrict users from being able to change their username just by using Access Control (under User Management menu).
The user module access control settings have a check box for 'change own username'.
I haven't tried it myself - just came across this and thought I'd do a quick post - sorry if it's not what you are after.
Why don't you install
Why don't you install nodeprofile and then you can change profiles according to roles?
Here's some code that I
Here's some code that I wrote to disable, but still show the title field of a node.
This takes the keys of the $user->roles array (which are built from the role table, so they wont change) and then compares them to the keys in the blocked users array. You need to use the same KEYS in the blocked array as in the role table.
This is added into the node.module on line 2964.
Not the best way to do this because if you update, you may lose this function, but it works.
Also checks if there is a title already, so the same function works on the add and edit pages. On the add, the field is still available.
hope this helps someone.