By Richard_ on
Hello, I was trying to find some code I can use but most of them deal with roles condition for users that are viewing pages not roles of a user's profile.
I wish to setup new tab in user profile, but would like to have this tab only on those profiles where profile owner is certain role.
Example:
UserXYZ is assigned with role nr.3. I want every user that is a member of role 3 to have new TAB in their profile called "MyStories" (i will set-up this content with views).
If you open user profile that is not a member of role nr.3, I do not want to display this TAB menu item on his profile.
Any suggestion will be very appreciated.
Thank you.
Comments
I have not tried this but
I have not tried this but you can control access to the view by role (part of basic information for view) and you can make the view available as a tab. So combining the two should get you what you want.
Thank you for your reply
Thank you for your reply nevets, but what you suggest is "who is able to access" the view and that is not what I am after.
I need to show content on user profile only if the owner of the profile is certain role - not the user that is viewing profile...
There is an option in the views where I can filter out content by role, but it doesnt affect constructing of the TAB menu - only the content is empty.
So what i need is new module with menu hook where I put condition/limit to certain role.
Something simmilar to this }but that is for node not for user profile:
http://drupal.org/node/162566
Basically something like this:
IF (profile owner == role3) {
print tab }
Hmm but I am not coder and do not know how excatly should I get these data...
Ive been working on somthing that might help, if your using Bio
Íve almost finished a module/plug in for the Bio module. Once set up it automatically assigns the Bio node a taxonomy term based on the owners role.
The module matches the owners role against a preset vocabulary (e.g. Roles vocabulary containing {admin, authenticated user, privileged user} ), when matches are found, they are applied.
With the taxonomy in place, you can use things like Taxonomy Access Control or similar (there may be a module to display menu items based on taxonomy).
Once its published (still one tweak left) i will post a link to it... if your impatient, email me and i will see if i can send you a pre-released copy).
Alternatively you will need to do some query work (or use user_load) based on the UID of the profile.
a_c_m
--
acmconsulting.eu
Bio role terms
http://drupal.org/project/bio_role_terms
--
acmconsulting.eu
module
Thank you for your reply,
meanwhile I have tried to setup new module with hook for menu tab.
I am not coder and I do not know how to build querry so that i can work with UID and RID (role ide).
I believe that it needs only little (but very important changes). It works without user role conditional.
Thank you for any hints.
I would change the test for
I would change the test for role like this (goes inside if ( $account ) {)
Thank you for your help
Thank you for your help nevets. I have got one error: "The second argument should be either an array or an object"
So I made it an array (at least I think so).
But anyway, this doesnt seem to work :( I have leaved out querry for role, because I do not know wheter it was done correctly ...
See what I have after your suggeston:
Opps, typo on my part,
Opps, typo on my part,
array_key_exists($desired_rid, array($user->roles))should have beenarray_key_exists($desired_rid, array($account->roles))Again, thank you for your
Again, thank you for your effort nevets.
Unfortunatelly your suggestion didnt work, but you gave me some direction into my thinking and I have figured it out somehow and it works perfectly.
Here is the final code:
Hi Richard, did you try this
Hi Richard, did you try this with nested tabs. I have three views that I would like to add as secondary tabs and only show them on profile of members in a certain role. Can you help please. Thanks