i use Drupal7, advanced forum & author pane

Here is an example of what I am trying to do: http://drupal.org/files/issues/test-forum-posts.jpg

avatar ( picture)
user name (jack)
role (moderator) <---- how to add this (just this)
.....

I looked everywhere but I have not found a real solution.

NB: I'm not an expert in php

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Michelle’s picture

The quick answer is to use $user->roles.

Since you aren't good with PHP, I suspect that isn't enough and will leave this active until I or someone else has time to write out the whole snippet for you.

honline’s picture

ok, I would wait and thank you even when

Scyther’s picture

Status: Active » Postponed

Would you like to display all roles that the user has or how many?

If the users is only a authenticated user should it say 'authenticated user' then or nothing, or what?

Please give some more info please and I will make a example as soon as possible if not Michelle gets to it first.

honline’s picture

Would you like to display all roles that the user has or how many? yes, he did have one role to user

If the users is only a authenticated user should it say 'authenticated user' then or nothing, or what? yes, authenticated users have also displayed their role as all other

and thank you in advance for your help, this is very nice

Scyther’s picture

Version: 7.x-2.0-alpha3 » 7.x-2.x-dev
Status: Postponed » Active

Here is a code snippet that you could add to your author-pane.tpl.php file to display all roles that the author has.

<div class="author-pane-line author-roles">
  <?php print implode(', ', $account->roles); ?>
</div>

It might be that the site that was in the picture uses the User titles module.

honline’s picture

FileSize
7.49 KB

thank you for your response, but it did not work.

I add your code to the file like you'd tell me, but nothing appears in the profile.

I attached the file that has modiffier comment, in case you want to see if something is wrong.

And for the Module User titles there are unfortunately not diponible to version 7 of drupal :(

Scyther’s picture

Did you edit the template in the Advanced Forum folder or in Author Pane?

Do you want to display the user Roles or User titles? The code snippet is for the user Roles.

honline’s picture

Did you edit the template in the Advanced Forum folder or in Author Pane? in Author Pane (i edit -->/sites/all/modules/author_pane/author-pane.tpl.php)

The code snippet is for the user Roles. display the user Roles its ok

thank you for your response,

Scyther’s picture

Test and edit the: /sites/all/modules/advanced_forum/styles/naked/advanced-forum.naked.author-pane.tpl.php instead.

honline’s picture

^_^ thank you very much for your help

it work

Scyther’s picture

Status: Active » Closed (fixed)
Sms2luv’s picture

I am using blue lagoon style for advance forum, how can I add the snippet to display user role

Scyther’s picture

Doesn't it work if you edit the advanced-forum.naked.author-pane.tpl.php file in the naked style folder? Since blue lagoon uses the naked style as base style it should work. If not, try to copy the tpl file from naked to the blue lagoon folder.

Sms2luv’s picture

Thanks a lot it really works.
But there is an issue with the display
I am getting the following text in my forums.
Kerry
\u2028\240 authenticated user\u2028
\u2028
Offline
Joined: 06/23/2012 - 19:54
---------------------------------------
Ignore the dashes.

I want it to be displayed in a different way like this.

Kerry
Member
Offline
Joined :
-----------------------------------
Ignore dashes

I don't want the numbers to come next to user role

Scyther’s picture

Don't know why you get thoose numbers. What type of char set do you have?

Sms2luv’s picture

What is char set

Scyther’s picture

Is your theme/file writen i UTF-8 or something else? It seems to be a UTF code "u2028".

Sms2luv’s picture

I am using lite jazz theme by roopletheme

Sms2luv’s picture

I tried to change the theme and in garland, bartik also the issue remains the same
What can be done about this.

Scyther’s picture

I don't know what the problem is. And this is not the right issue for that either. Try to write in the drupal support forums.

Sms2luv’s picture

I tried posting in main Drupal forum still there is no response
Please help me, can you please give me dome suggestion

Scyther’s picture

Sorry but I don't know what the problem could be.

Sms2luv’s picture

In your previous post you mentioned that we can have option to display a particular role if users has more than 1 roles how can I go about that

ymoss’s picture

i dont know why this didnt work for my AP,,, im using the 7.x-2.0-beta1
should i change to dev version for this to work? please help...

Sms2luv’s picture

I am using advance forum more style and changing naked tpl has not affect

Sms2luv’s picture

I edited advance forum more style author pane tpl and got it working but the issue remains the same
I am getting those weired number again.
It's a fresh Drupal installation.
Please help me in this, it's an essential part of the forum and I cannot miss it

Sms2luv’s picture

Thanks, Thanks, Thanks a lot.
Issue is resolved.
just one simple question.

i am admin of my site and when i post any topic, Author pane displays it as authenticated user, administrator
i want it to pick up the highest value.
For example in this case it should Administrator and not Authenticated user.

If a user is a moderator, then it should be just Moderator and not Authenticated user.

Scyther’s picture

@Sms2luv: could you please stop spam this issue!! This issue is about how to display the user roles and it has been explained. You have to take your problem to the forums or other sites because this has nothing to do with this!

Sms2luv’s picture

Excuse me it's not spamming
I am just asking a simple question and it is in scope of drupal
I am not asking about rocket science it just a simple query of php

Scyther’s picture

You have posted 4 "please help me" and once "any update on this". So you are bumping this issue that is even closed and fixed! That I count as spam. So PLEASE try Drupal.org forums to get help and not this issue.

Sms2luv’s picture

@Scyther please check #4 comment, you have asked which role shoudl be displayed, so i have just asking you the same thing.

Michelle’s picture

What you are asking no longer has anything to do with Author Pane. It's basic PHP. If you don't know how to write PHP, you might want to learn at least a little so you aren't dependent on others to write it for you. If you don't want to do that, asking your questions in the forums will get a lot more eyes on it than asking off-topic questions in a project's issue queue.

The variable in question is $account->roles as was stated above. You've already been told how to put it into Author Pane. The only remaining question is how to choose one value out of the array and that can be done with a foreach loop with a test inside to check the current value against the role(s) you want to print.

Michelle

Sms2luv’s picture

Good Unity

Sms2luv’s picture

Instead of writing the whole story don't you think that you could had replied with resolution

Michelle’s picture

Instead of spending 6 days begging for someone to do your work for you, don't you think you could have taken some initiative yourself? I told you exactly how to do it; you just need to look up the syntax. That's all the more fish I'm throwing you. Time to learn how to bait that hook.

Michelle

Sms2luv’s picture

Michelle seems that you think yourself super smart

I really don't know why you are poking your nose here
You are not required here bye

Michelle’s picture

Sorry for poking my nose into an issue in the queue of the module I wrote. What was I thinking?

Sms2luv’s picture

SO if you removed your frustration, can we come back to the topic

Michelle’s picture

Now you don't approve of my gender? This is getting quite silly, don't you think? Time to move along... Nothing more to be done here. Why don't you find yourself a nice book on PHP and spend your time more constructively?

Michelle

Sms2luv’s picture

sorry to be rude, but if you think that you are super smart you deserve this language

Michelle’s picture

Ok, this is beyond silly and into boring. Locking unproductive thread.