I have this following code that is printing twice the user group. Thanks in advance.
<?php
$terms = array();
$terms_tags = get_the_terms( $current_user->ID, array( 'user-group' ) );
foreach ( $terms_tags as $term_tag ) {
$terms[$term_tag->slug] = $term_tag->name;
echo $term_tag->slug. ' ';
}
?>
The WordPress docs are indicating that the second parameter for get_the_terms()
should be a string, not an array. Could you check this?
Try it like this:
<?php
$terms = array();
$terms_tags = get_the_terms( $current_user->ID, 'user-group' );
foreach ( $terms_tags as $term_tag ) {
$terms[$term_tag->slug] = $term_tag->name;
echo $term_tag->slug. ' ';
}
?>
By now this is the only "problem" i see in your code.