Hi,
I don't know how to display secondary user role.
For example, I have member who is "Senior" and also a "Team Leader" which is his primary and secondary role. Is there any way to show user's secondary role in their info?
Thanks!
Hello @elvina
I guess I need to add this part in my theme functions
Could you please provide me with full line or position where to put this hook?
Thanks!
Please use the following code:
add_filter('wpdiscuz_after_label', function ($afterLabel, $comment) {
if (!empty($comment->user_id)) {
if ($comment->user_id == 6) {
um_fetch_user($comment->user_id);
if ($role = um_user('role')) {
$afterLabel .= '<div class="wc-comment-label-secondary"><span>' . UM()->roles()->get_role_name($role) . '</span></div>';
}
}
}
return $afterLabel;
}, 10, 2);
Put the code in your active theme's functions.php file.
@astghik
sorry no changes I mean, nothing happens 🙁
If you have a cache plugin, please delete the plugin cache and check again.
Hi, I just did it again
Clear plugin cache+site casche+browser cache+open in private window and no luck 🙁
Btw, UM roles are in format "um_role" not like default wp "role", maybe that is making issue here?
Please try this one:
add_filter('wpdiscuz_after_label', function ($afterLabel, $comment) {
if (!empty($comment->user_id)) {
um_fetch_user($comment->user_id);
if ($role = um_user('role')) {
$afterLabel .= '<div class="wc-comment-label-secondary"><span>' . UM()->roles()->get_role_name($role) . '</span></div>';
}
}
return $afterLabel;
}, 10, 2);
and it's duplicating
Please navigate to Dashboard > Comments > Setting > Styling admin page, put the following CSS code in the "Custom CSS code: textarea.
#wpcomm .wc-comment-label{
height: 50px !important;
}
.wc-comment-label-secondary {
color: #00B38F;
font-size: 12px;
}
The red marked value can be changed.
I hope this will be helpful.
If you need some other style customizations regarding the secondary usergroup displaying, you'll need to do it yourself, based on the example I've provided above. Please note, that we don't provide support for style customization, we may help in 1-2 simple questions related to colors and background but not more. We only help with general questions and issues. We can not help you customize all components of your website. These are custom requirements and should be done by website owners.
Thank you for your understanding.
Thank you for your reply
Actually I didn't ask for any customisation or whatsoever, and I know you're not here for that.
Everything there is default by WP Discuss and its working with per your integration with UM and MyCRED
My question was is it possible to show first and second role and I was expecting to see it next to main role something like:
- main role, second role
or in my case
- senior, team leader
Now turns our much complicated that we were all expected.
Unfortunately this is not solution, please check screenshoot what we have now,
1. role displaced
2. role displaced and repeating.
If we can not sort is out now if I may suggest to consider this in your next upgrade or something. It would be nice (and important for me) to show second role displayed.
Thank you for your time, knowledge and all inconvenience if I cause any.
M.
role displaced and repeating.
Hi @elvina and thank you for reply.
I believe that I this setup is done correctly
I did have WP Senior role, that's true, this role was deleted and new one was created trough UM. From some reason this one is still visible trough WPD but in Phrases is empty and shouldn't be visible anyway.
Please check, thanks!
Please try to reset the phrases from the Dashboard > Comments > Phrases > Comment tab.
Then delete all caches and check again. The issue should be solved.
Please send the admin login details to info[at]gvectors.com email address to allow us to check it.
Sorry for the late response.
The developers have checked your website and don't find any issues with wpDiscuz plugin. The code we've provided works fine.
We see the Senior user role in UM settings so the plugin, thus wpDiscuz displayed the "Senior" under the avatar, and as we already mentioned you can change the user roles name as you want.
The solution to the question you've mentioned is already provided and works properly.
Maybe, we will add the secondary usergroup feature in the near feature update (no ETA).