That’s the code that worked on our test site – you can see the thread here: https://wp50test01.vnxv.com/forum/a-private-forum-for-members/what-roles-does-this-user-have/. (You might have to register an account to see the thread).
Once you’re viewing the thread, the user spuser02 has three memberships (Guests, Members and VIP). But only the first one is shown – “Guest”. You can see the other hidden two if you look in the html source code (search for the string “VIP” and you’ll get to the area where that data is located).
Your classes or IDs might be different for various reasons so you might have to use your browser tools to get the right CSS IDs and Classnames.
Thanks.