Notifications
Clear all

[Solved] Secondary role display

21 Posts
3 Users
0 Reactions
2,440 Views
(@markoz)
Member Customer
Joined: 6 years ago
Posts: 31
Topic starter  

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!


   
Quote
Elvina
(@elvina)
Support
Joined: 5 years ago
Posts: 1403
 

Hi @markoz,

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

wpdiscuz_after_label

   
ReplyQuote
(@markoz)
Member Customer
Joined: 6 years ago
Posts: 31
Topic starter  

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)
Support
Joined: 5 years ago
Posts: 1403
 

@markoz,

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

 


   
ReplyQuote
(@markoz)
Member Customer
Joined: 6 years ago
Posts: 31
Topic starter  

@elvina

thanks for reply

 

I'm using Ultimate Member


   
ReplyQuote
Astghik
(@astgh)
Illustrious Member Admin
Joined: 7 years ago
Posts: 6149
 

@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)
Member Customer
Joined: 6 years ago
Posts: 31
Topic starter  

@astghik

sorry no changes I mean, nothing happens 🙁


   
ReplyQuote
Elvina
(@elvina)
Support
Joined: 5 years ago
Posts: 1403
 

@markoz

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


   
ReplyQuote
(@markoz)
Member Customer
Joined: 6 years ago
Posts: 31
Topic starter  

@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)
Support
Joined: 5 years ago
Posts: 1403
 

@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)
Member Customer
Joined: 6 years ago
Posts: 31
Topic starter  

@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)
Member Customer
Joined: 6 years ago
Posts: 31
Topic starter  
Screen Shot 2019 11 13 at 16.09.06

 

and it's duplicating 


   
ReplyQuote
Elvina
(@elvina)
Support
Joined: 5 years ago
Posts: 1403
 

@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)
Member Customer
Joined: 6 years ago
Posts: 31
Topic starter  

@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)
Support
Joined: 5 years ago
Posts: 1403
 
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)
Member Customer
Joined: 6 years ago
Posts: 31
Topic starter  

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)
Support
Joined: 5 years ago
Posts: 1403
 

@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)
Member Customer
Joined: 6 years ago
Posts: 31
Topic starter  

@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)
Support
Joined: 5 years ago
Posts: 1403
 

@markoz,

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

 


   
ReplyQuote
Elvina
(@elvina)
Support
Joined: 5 years ago
Posts: 1403
 

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


   
ReplyQuote
Page 1 / 2
Share:
Scroll to top