Show special roles on user profile I have a little issue on drupal 7. I want a little object/field on the userprofile. This object/field shoud show special roles of the user (special = "admin, moderator ...").
And is it possible that this object comes directly after the username ?

(I am very sorry for my bad english. I hope you understand my question)
So I found a solution that works for me.

Modules used:


Display Suit
Display Suit Extra
PHP filter
(I hope I didn´t forget one)


Here is how I did it ...

1.Go to a Profil

2.Click on "Edit"

3.Switch to the tab "Manage display" (right upper corner of the overlay)

4.scroll down to "custom fields" and click it

5.click "Add a code field"

6.check "User" on "Entities" and change the Text format in the "Field code" to "PHP code"

7.Now type the following in the "Field code" (Add/Change the Roles You have)

&lt;?php $account = user_load(arg(1));?&gt;
&lt;div class="user-roles"&gt;
    &lt;ul&gt;
        &lt;?php foreach($account-&gt;roles as $role): ?&gt;
            &lt;?php if($role != "authenticated user"): ?&gt;
&lt;?php //--------------HERE YOU NEED TO ADD/CHANGE THE ROLES YOU HAVE------------------- ?&gt;
                    &lt;li class="user-role- &lt;?php 
                    if($role == '[Your Role]'){ echo 'user-role-[your role]'; }
                    elseif($role == '[Your Role]'){ echo 'user-role-[your role]'; }
                    elseif($role == '[Your Role]'){ echo 'user-role-[your role]'; }?&gt;"&gt;
&lt;?php //------------------------------------------------------------------------------- ?&gt;
                    &lt;?php print $role; ?&gt;
                &lt;/li&gt;
            &lt;?php endif; ?&gt;
        &lt;?php endforeach; ?&gt;
    &lt;/ul&gt;
&lt;/div&gt;



Press "Save"


That´s it. I hope it works for You too.

(Again I apologize for my bad English. It can gladly edit for correcting my grammar)