Add S2member in comments

Hello everyone,

I tried to add php code in order to show S2member label in comments, but nothing work :frowning:
Any idea of how to do that ?

I would like to display this [s2Get constant=“S2MEMBER_CURRENT_USER_ACCESS_LABEL” /]

This is the code I put in function.php :
Code:

```
if ( ! class_exists( 'WPB_Comment_Author_Role_Label' ) ) :
class WPB_Comment_Author_Role_Label{
public function __construct() {
add_filter( 'get_comment_author', array( $this, 'wpb_get_comment_author_role' ), 10, 3 );
add_filter( 'get_comment_author_link', array( $this, 'wpb_comment_author_role' ) );
}// Get comment author role
function wpb_get_comment_author_role($author, $comment_id, $comment) {
$authoremail = get_comment_author_email( $comment);if (email_exists($authoremail)){
$commet_user_role = get_user_by( 'email', $authoremail );
$comment_user_role = $commet_user_role->roles[0];
// HTML output to add next to comment author name
$this->comment_user_role = ' <span class="comment-author-label comment-author-label-'.$comment_user_role.'">' . ucfirst($comment_user_role) . '</span>';
} else {
$this->comment_user_role = ";
}
return $author;
}
// Display comment author
function wpb_comment_author_role($author){
return $author .= $this->comment_user_role;
}
}
new WPB_Comment_Author_Role_Label;
endif;
```

Also tried :

```
function get_role($user_id)
{
    if(is_int($user_id))
    {
        $user = new WP_User( $user_id );
        if ( !empty( $user->roles ) && is_array( $user->roles ) ) 
        {
            foreach ( $user->roles as $role )
                echo $role;
        }
    }
    else
        echo "Something else";
}
``` 

but then I have : Cannot redeclare get_role() (previously declared in wp-includes/capabilities.php:830)
:confused:

bump !

The shortcode relates to the current user. If the author of the comment is not the current user, nothing will show.