Support » Plugin: User Groups » Echo user category

Viewing 4 replies - 1 through 4 (of 4 total)
  • I need the same thing. Please help. How to get current user group?

    Plugin Author Zack Katz

    (@katzwebdesign)

    Please describe your request further.

    toto

    (@toto)

    <?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

    (@hodzickenan)

    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.