Show group name
Quote from Asgaros on May 15, 2017, 10:57 amHello 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);
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);
Quote from Yworld on May 15, 2017, 11:15 amDid 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>'; }
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>'; }
Quote from Asgaros on May 15, 2017, 11:35 amYou 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. 🙂
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. 🙂
Quote from Yworld on May 15, 2017, 12:24 pmQuote from Asgaros on May 15, 2017, 11:35 amAlso check the arguments of the hook you are using. It has no user-group-stuff inside.
Did not understand what argument to add 😐
Quote from Asgaros on May 15, 2017, 11:35 amAlso check the arguments of the hook you are using. It has no user-group-stuff inside.
Did not understand what argument to add 😐
Quote from Asgaros on May 15, 2017, 3:54 pmPlease 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); }
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); }
Quote from Asgaros on May 15, 2017, 4:15 pmYes, 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. 🙂
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. 🙂