Title: Echo user category
Last modified: August 20, 2016

---

# Echo user category

 *  [heatstroke](https://wordpress.org/support/users/heatstroke/)
 * (@heatstroke)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/echo-user-category/)
 * Hi!
 * I need to echo the ID and Name of the user categories. That is, echo terms IDs
   and names. Is it possible? Any tip about the code?
 * Thanks a lot and good job! 😉
 * [http://wordpress.org/extend/plugins/user-groups/](http://wordpress.org/extend/plugins/user-groups/)

Viewing 4 replies - 1 through 4 (of 4 total)

 *  [toto](https://wordpress.org/support/users/toto/)
 * (@toto)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/echo-user-category/#post-3183697)
 * I need the same thing. Please help. How to get current user group?
 *  Plugin Author [Zack Katz](https://wordpress.org/support/users/katzwebdesign/)
 * (@katzwebdesign)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/echo-user-category/#post-3183705)
 * Please describe your request further.
 *  [toto](https://wordpress.org/support/users/toto/)
 * (@toto)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/echo-user-category/#post-3183706)
 *     ```
       <?php
           function replace_id_for_slug($option){
           	$categories = get_categories("hide_empty=0&taxonomy=product_tag");
           	preg_match('/value="(\d*)"/', $option[0], $matches);
           	$id = $matches[1];
           	$slug = "";
           	foreach($categories as $category){
           		if($category->cat_ID == $id){
           			$slug = $category->slug;
           		}
           	}
           	return preg_replace("/value=\"(\d*)\"/", "value=\"$slug\"", $option[0]);
           }
   
                 $select = wp_dropdown_categories("taxonomy=product_tag&hierarchical=1&show_count=1&echo=0");
   
           $select = preg_replace("#<select([^>]*)>#", "<select$1 onchange='return this.form.submit()'>", $select);
           $select = preg_replace_callback("#<option[^>]*>[^<]*</option>#", "replace_id_for_slug", $select);
           $select = str_replace("cat","product_tag",$select);
           echo $select;
           ?>
       ```
   
 *  [Kenan](https://wordpress.org/support/users/hodzickenan/)
 * (@hodzickenan)
 * [12 years, 11 months ago](https://wordpress.org/support/topic/echo-user-category/#post-3183708)
 * I have an invoice template, and I would like to echo current user’s group name
   inside that template.
    I tried this:
 *     ```
       $terms = get_terms( 'user-group' );
       echo ($user->user-group);
       ```
   
 * but, of course, **it’s not working.** It just echo 0.
    How to do that? Thanks

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Echo user category’ is closed to new replies.

 * ![](https://ps.w.org/user-groups/assets/icon-256x256.jpg?rev=1179282)
 * [User Groups](https://wordpress.org/plugins/user-groups/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/user-groups/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/user-groups/)
 * [Active Topics](https://wordpress.org/support/plugin/user-groups/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/user-groups/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/user-groups/reviews/)

## Tags

 * [category](https://wordpress.org/support/topic-tag/category/)
 * [id](https://wordpress.org/support/topic-tag/id/)
 * [name](https://wordpress.org/support/topic-tag/name/)
 * [user](https://wordpress.org/support/topic-tag/user/)

 * 4 replies
 * 4 participants
 * Last reply from: [Kenan](https://wordpress.org/support/users/hodzickenan/)
 * Last activity: [12 years, 11 months ago](https://wordpress.org/support/topic/echo-user-category/#post-3183708)
 * Status: not resolved