By man.of.munch on
Is it possible for the user's role to be displayed underneath their user pictures in both the comments, nodes and on their profile pages?
Is it possible to make this happen for only certain roles (so a moderator or administrator would have the role text, but a normal user would not)?
Comments
looking for an answer as well
so if you have it please let me know
i would like the profile picture to be add auto to the node publish by this profile.
thank you
Managing Partner at Reasonat
Still No Idea
Sorry, I still don't know. Is there anyone who know the answer???
u can use User Badges
u can use User Badges module. usually it is used to display pictures according to the user role.u can type needed text in photoshop and display it with needed roles)
also there is User Titles module,but i havent seen it, maybe u should review it too.
unfortunately both are for
unfortunately both are for Drupal 5 yet no 6.
is there another module you know about?
thank you
Managing Partner at Reasonat
I'm on 6 too
That is a shame, I am using drupal 6 too.
Override the template.
If you create a custom user-picture.tpl.php for your theme you can display whatever information you wish, based on whatever criteria you want.
Read this --> http://api.drupal.org/api/file/modules/user/user-picture.tpl.php
You should familiarize yourself with the api as it will help you.
How is this done?
I read the link you posted and it seems pretty straightforward however I don't know php and have no idea how to print the user's role.
Do you have any code for this, or is there anywhere that I can find some?
I've been looking for an
I've been looking for an option to display the User's Role as well. Nothing seems to be available for Drupal6 which is a wee bit frustrating. I came across this. I am yet to try it. Let me know how it goes.
To get the role(s) you
To get the role(s) you should be able to go through the global $user object to the roles array. Keep in mind though that a user may well have more than one role (apparently, I can't claim to be a ninja). So you need to either grab just one or concatentate them all into a single string.
Search from roles on this page (http://www.bywombats.com/blog/ryan/10-25-2007/checking-if-drupal-user-ha...) and you should get an idea of what needs to happen.
Barrett, Thanks for
Barrett,
Thanks for responding but I'm a total newb and don't understand what I should edit. I however found this will it work on D6?
Okay. Start from the source
Okay. Start from the source code of the user-picture.tpl.php (http://api.drupal.org/api/file/modules/user/user-picture.tpl.php/6/source) which gforce301 linked you to earlier in the thread. That gives you a shell file that you can start modifying to work how you want.
Then add in the role handing you just linked to. You already have a user object though, so you don't need to load one explicitly. The code you referenced is also only going to print the last role in the user's list of roles, so it's probably desirable to modify that code to concatenate them all into one string which you can print. The code below is what I'd use.
Then add the snippet to the tpl.php file under where it prints the picture variable, save the whole thing to user-picture.tpl.php and save that file in your theme directory.
Keep in mind, I haven't tested the code, but it should work.
change or eliminate "authenticated user"
Thanks,
at least this solution works - lots of others I tried along the way didn't.
Now I am wondering, if there is a simple way to eliminate "authenticated user" from the list or to rename it to something shorter and to the point, i.e. "member".
Thanks
just stick an if block before appending to roleList
Thanks
great - it works well and thanks for the quick help!!!!
I then found that the ($user->roles as $role) -of course returns- the roles of the person who is logged on.
I wanted to add the snippet to my user-profile.tpl.php file in order to jazz up the customised user profile on my site.
The answer seems to be to change the snippet for my purpose as follows by replacing $user for $account:
I then also wanted to add the Joining date / time joined and found the following snippets and changed them accordingly to show the details of the account not the user.
Of course for a lot of our much longer serving colleagues here all this is properly very obvious and even I must chuckle a bit looking back - how could it not have been clear - I am the $user and the others are the $accounts.
Great fun to learn all this and thanks to the credit crunch I have the time to do something interesting - and thanks to all those helping friends around here.
D'oh! Yeah, I completely
D'oh! Yeah, I completely misread what you were going for there. Glad you worked it out.