Hello.
I would like to know if there is a snippet to display the user role name on account page? Since I would like my customers to know which group they are in.
I have tried some codes that I found, but none of them work.
Thank you in advance.
Hello.
I would like to know if there is a snippet to display the user role name on account page? Since I would like my customers to know which group they are in.
I have tried some codes that I found, but none of them work.
Thank you in advance.
Hi Cathy,
You can use the following PHP snippet:
add_action('woocommerce_account_content', function(){
$user_id = get_current_user_id();
$group_id = get_user_meta($user_id,'b2bking_customergroup', true);
if (!empty($group_id)){
$group_name = get_the_title($group_id);
echo 'Your user is part of the group '.'<strong>'.$group_name.'</strong>';
}
});
and the result will be this:

Let me know if I can help,
Kind regards,
Stefan
Hi Stefan,
I have tried to use the snippet, but it did not work. I am not sure if I need to paste the snippet to other places.
Regards,
Cathy
This message is private.
This message is private.
This message is private.
Hi Stefan,
Thank you so much for your help. It works perfectly now.
Regards,
Cathy