[Solved] Secondary role display  

Page 1 / 2
  RSS

MarkoZ
(@markoz)
Member Customer
Joined: 1 year ago
Posts: 26
10/11/2019 9:12 am  

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?

Screen Shot 2019 11 10 at 09.04.28

 

Thanks!

This topic was modified 3 months ago by Elvina

Quote
Elvina
(@elvina)
Reputable Member Moderator
Joined: 5 months ago
Posts: 435
11/11/2019 12:27 pm  

Hi @markoz,

You can use the following hook to display the secondary role: 

wpdiscuz_after_label

ReplyQuote
MarkoZ
(@markoz)
Member Customer
Joined: 1 year ago
Posts: 26
11/11/2019 1:58 pm  

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!

 


ReplyQuote
Elvina
(@elvina)
Reputable Member Moderator
Joined: 5 months ago
Posts: 435
11/11/2019 4:54 pm  

@markoz,

For further support, please let us know the plugin you use to get the user's role.

 


ReplyQuote
MarkoZ
(@markoz)
Member Customer
Joined: 1 year ago
Posts: 26
11/11/2019 5:52 pm  

@elvina

thanks for reply

 

I'm using Ultimate Member


ReplyQuote
Astghik
(@astghik)
Support Team Admin
Joined: 2 years ago
Posts: 3513
12/11/2019 5:51 pm  

@markoz

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. 


ReplyQuote
MarkoZ
(@markoz)
Member Customer
Joined: 1 year ago
Posts: 26
12/11/2019 6:57 pm  

@astghik

sorry no changes I mean, nothing happens 🙁


ReplyQuote
Elvina
(@elvina)
Reputable Member Moderator
Joined: 5 months ago
Posts: 435
13/11/2019 1:27 pm  

@markoz

If you have a cache plugin, please delete the plugin cache and check again.


ReplyQuote
MarkoZ
(@markoz)
Member Customer
Joined: 1 year ago
Posts: 26
13/11/2019 1:45 pm  

@elvina

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? 


ReplyQuote
Elvina
(@elvina)
Reputable Member Moderator
Joined: 5 months ago
Posts: 435
13/11/2019 3:50 pm  

@markoz

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);

 


ReplyQuote
MarkoZ
(@markoz)
Member Customer
Joined: 1 year ago
Posts: 26
13/11/2019 4:03 pm  

@elvina

Screen Shot 2019 11 13 at 16.00.37

I can see it now but just on the wrong spot and format


ReplyQuote
MarkoZ
(@markoz)
Member Customer
Joined: 1 year ago
Posts: 26
13/11/2019 4:10 pm  
Screen Shot 2019 11 13 at 16.09.06

 

and it's duplicating 


ReplyQuote
Elvina
(@elvina)
Reputable Member Moderator
Joined: 5 months ago
Posts: 435
13/11/2019 4:56 pm  

@markoz,

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.


ReplyQuote
MarkoZ
(@markoz)
Member Customer
Joined: 1 year ago
Posts: 26
13/11/2019 5:13 pm  

@elvina

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, 

Screen Shot 2019 11 13 at 17.02.07

 

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.


ReplyQuote
Elvina
(@elvina)
Reputable Member Moderator
Joined: 5 months ago
Posts: 435
14/11/2019 12:20 pm  
Posted by: @markoz

role displaced and repeating.

It seems that you already have the "Senior" role, and create another one with the same "Senior" name using the Ultimate member plugin.

You should find and change the user roles name in the  Dashboard > Comments > Phrases > Comment tab page. See the screenshot below:
roles

ReplyQuote
MarkoZ
(@markoz)
Member Customer
Joined: 1 year ago
Posts: 26
14/11/2019 12:28 pm  

Hi @elvina and thank you for reply.

I believe that I this setup is done correctly 

Screen Shot 2019 11 14 at 12.23.19

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.

Screen Shot 2019 11 14 at 12.23.34

Please check, thanks!

 


ReplyQuote
Elvina
(@elvina)
Reputable Member Moderator
Joined: 5 months ago
Posts: 435
14/11/2019 4:23 pm  

@markoz,

Please try to reset the phrases from the Dashboard > Comments > Phrases > Comment tab.

second role

Then delete all caches and check again. The issue should be solved. 


ReplyQuote
MarkoZ
(@markoz)
Member Customer
Joined: 1 year ago
Posts: 26
14/11/2019 5:36 pm  

@elvina

I'm sorry but still...  🙁

Maybe you want to double check you code for integration with UM?

Screen Shot 2019 11 14 at 17.32.21

 


ReplyQuote
Elvina
(@elvina)
Reputable Member Moderator
Joined: 5 months ago
Posts: 435
15/11/2019 12:41 pm  

@markoz,

Please send the admin login details to info[at]gvectors.com email address to allow us to check it.

 


ReplyQuote
Elvina
(@elvina)
Reputable Member Moderator
Joined: 5 months ago
Posts: 435
19/11/2019 3:56 pm  

@markoz,

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).

This post was modified 2 months ago by Elvina

ReplyQuote
Page 1 / 2
Share: