Forum breadcrumbs – You are here:Asgaros Support ForumSupportShow group name
Please or Register to create posts and topics.

Show group name

Page 1 of 2Next

Hi Thomas

How to display the name of the group under the avatar?

Thank you.

Hello Yworld,

there are a couple of functions in the AsgarosForumUserGroups class you can use:

// Returns all usergroups.
public static function getUserGroups();

// Returns usergroup by id/slug/name/term_taxonomy_id.
public static function getUserGroupBy($value, $by = 'id');

// Returns color of usergroup.
public static function getUserGroupColor($term_id);

// Returns usergroups of user.
public static function getUserGroupsForUser($user_id, $fields = 'all');

// Returns users in usergroup.
public static function getUsersInUserGroup($usergroup_id);

// Counts users in usergroup.
public static function countUsersInUserGroup($usergroup_id);

// Checks if a user is in a specific user group.
public static function isUserInUserGroup($userID, $userGroupID);

In your case the following function could be interesting:

$groupsOfUser = AsgarosForumUserGroups::getUserGroupsForUser($user_ID);

 

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

Thank you!

Did not work out 🙂

add_action('asgarosforum_after_post_author', 'my_asgarosforum_after_post_administration', 20, 2);

function my_asgarosforum_after_post_administration($groupsOfUser, $user_ID) {

$groupsOfUser = AsgarosForumUserGroups::getUserGroupsForUser($user_ID, $author_posts);
 echo '<div>'.$groupsOfUser.'</p></div>';

 }

You are using a wrong second argument. It should look like this:

AsgarosForumUserGroups::getUserGroupsForUser($user_ID);

Also check the arguments of the hook you are using. It has no user-group-stuff inside. 🙂

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 May 15, 2017, 11:35 am

Also check the arguments of the hook you are using. It has no user-group-stuff inside. 🙂

Did not understand what argument to add 😐

It does not work out

Do not get this done?

Please try this code:

add_action('asgarosforum_after_post_author', 'my_asgarosforum_after_post_administration', 20, 2);
function my_asgarosforum_after_post_administration($author_id, $author_posts) {
  $groupsOfUser = AsgarosForumUserGroups::getUserGroupsForUser($author_id);
  print_r($groupsOfUser);
}

 

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

Here so

Yes, its fine. Its an object of usergroups-terms which contains all necessary data. You can modify and display them as you want. Its up to you. 🙂

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