Forum breadcrumbs – You are here:Asgaros Support ForumSupportShow forum user role
Please or Register to create posts and topics.

Show forum user role

Showing forum user role below username.

Example.
Profile Picture
Username
Forum User Role <- This is what i want to add
XX Posts.

Sorry if my English bad.

Hello slime0k,

please add the following code to your themes functions.php-file to show the user-role below the username:

function show_forum_role($user_id, $post_counter) {
  echo '<br>'.AsgarosForumPermissions::getForumRole($user_id);
}
add_action('asgarosforum_after_post_author', 'show_forum_role', 10, 2);

 

If you want to support the development of Asgaros Forum, you can leave a good review or donate. Thank you very much!

How about User Group we create?
See attachment. Thanks.

Sorry i ask to much.

Uploaded files:
  • Screenshot-188.png

Hallo slime0k,

ich habe es nach langem probieren hinbekommen.

Wenn´s Dir gefällt schicke ich Dir gerne den Code für die funktions.php

http://www.myhakotrac.de/forum/

Gruß Robert

With usergroups included the code could look like this:

function show_forum_role($user_id, $post_counter) {
  echo '<br>'.AsgarosForumPermissions::getForumRole($user_id);

  // Show user groups.
  $userGroups = AsgarosForumUserGroups::getUserGroupsOfUser($user_id, 'names');

  if (!empty($userGroups)) {
    foreach ($userGroups as $value) {
      echo '<br>'.$value;
    }
  }
}
add_action('asgarosforum_after_post_author', 'show_forum_role', 10, 2);

But keep in mind that those functions are not official API-functions yet and some of them will change in future releases because I am still working on refactoring and optimizing the code-base. So when something crashes after an update please let me know so I can provide you some updated code-snippet.

slime0k and digitalant have reacted to this post.
slime0kdigitalant
If you want to support the development of Asgaros Forum, you can leave a good review or donate. Thank you very much!
Quote from Asgaros on January 30, 2018, 12:31 pm

With usergroups included the code could look like this:

function show_forum_role($user_id, $post_counter) {
  echo '<br>'.AsgarosForumPermissions::getForumRole($user_id);

  // Show user groups.
  $userGroups = AsgarosForumUserGroups::getUserGroupsOfUser($user_id, 'names');

  if (!empty($userGroups)) {
    foreach ($userGroups as $value) {
      echo '<br>'.$value;
    }
  }
}
add_action('asgarosforum_after_post_author', 'show_forum_role', 10, 2);
  1. function show_forum_role($user_id, $post_counter) {
  2. echo ‘<br>’.AsgarosForumPermissions::getForumRole($user_id);
  3. // Show user groups.
  4. $userGroups = AsgarosForumUserGroups::getUserGroupsOfUser($user_id, ‘names’);
  5. if (!empty($userGroups)) {
  6. foreach ($userGroups as $value) {
  7. echo ‘<br>’.$value;
  8. }
  9. }
  10. }
  11. add_action(‘asgarosforum_after_post_author’, ‘show_forum_role’, 10, 2);
function show_forum_role($user_id, $post_counter) {
  echo '<br>'.AsgarosForumPermissions::getForumRole($user_id);

  // Show user groups.
  $userGroups = AsgarosForumUserGroups::getUserGroupsOfUser($user_id, 'names');

  if (!empty($userGroups)) {
    foreach ($userGroups as $value) {
      echo '<br>'.$value;
    }
  }
}
add_action('asgarosforum_after_post_author', 'show_forum_role', 10, 2);

But keep in mind that those functions are not official API-functions yet and some of them will change in future releases because I am still working on refactoring and optimizing the code-base. So when something crashes after an update please let me know so I can provide you some updated code-snippet.

Okay.

Thank you.

Quote from Asgaros on January 30, 2018, 12:31 pm

With usergroups included the code could look like this:

function show_forum_role($user_id, $post_counter) {
  echo '<br>'.AsgarosForumPermissions::getForumRole($user_id);

  // Show user groups.
  $userGroups = AsgarosForumUserGroups::getUserGroupsOfUser($user_id, 'names');

  if (!empty($userGroups)) {
    foreach ($userGroups as $value) {
      echo '<br>'.$value;
    }
  }
}
add_action('asgarosforum_after_post_author', 'show_forum_role', 10, 2);
  1. function show_forum_role($user_id, $post_counter) {
  2. echo ‘<br>’.AsgarosForumPermissions::getForumRole($user_id);
  3. // Show user groups.
  4. $userGroups = AsgarosForumUserGroups::getUserGroupsOfUser($user_id, ‘names’);
  5. if (!empty($userGroups)) {
  6. foreach ($userGroups as $value) {
  7. echo ‘<br>’.$value;
  8. }
  9. }
  10. }
  11. add_action(‘asgarosforum_after_post_author’, ‘show_forum_role’, 10, 2);
function show_forum_role($user_id, $post_counter) {
  echo '<br>'.AsgarosForumPermissions::getForumRole($user_id);

  // Show user groups.
  $userGroups = AsgarosForumUserGroups::getUserGroupsOfUser($user_id, 'names');

  if (!empty($userGroups)) {
    foreach ($userGroups as $value) {
      echo '<br>'.$value;
    }
  }
}
add_action('asgarosforum_after_post_author', 'show_forum_role', 10, 2);

But keep in mind that those functions are not official API-functions yet and some of them will change in future releases because I am still working on refactoring and optimizing the code-base. So when something crashes after an update please let me know so I can provide you some updated code-snippet.

ok so if it crashes we can just simple remove the code from functions right ?

Can you tell us the error-message? Maybe we can find a fix for it.

If you want to support the development of Asgaros Forum, you can leave a good review or donate. Thank you very much!

Hello

Is it possible to show user role (or nickname) in the color which assigned to user role in settings?

Hello @childledj

This is on my todo-list:

https://github.com/Asgaros/asgaros-forum/issues/144

If you want to support the development of Asgaros Forum, you can leave a good review or donate. Thank you very much!