How to make a specific user role stand out?
-
Hi,
We have a BP site with Activity Plus which has a custom user role of “Approved Member”
Is there any way to make the role stand out in the activity stream maybe with an icon or custom colour?
Thanks in advance
-
Hi @debayne,
I hope you are well today and thank you for your question.
To achieve this do the following things
Add the following CSS code in the style.css file of your child theme or add it in your site using the following plugin.
http://wordpress.org/plugins/simple-custom-css
#activity-stream .activity_update.subscriber { background-color: #eaeaea; }
Add the following code in the functions.php file of your child theme or add it in your site using any of the following plugin.
http://wordpress.org/plugins/code-snippets/
http://wordpress.org/plugins/add-actions-and-filters/function wp_get_user_roles_by_id( $id ) { $user = new WP_User( $id ); if ( empty ( $user->roles ) or ! is_array( $user->roles ) ) return array (); $wp_roles = new WP_Roles; $names = $wp_roles->get_names(); $out = array (); foreach ( $user->roles as $role ) { if ( isset ( $names[ $role ] ) ) $out[ $role ] = $names[ $role ]; } return strtolower( implode(" ", $out) ); } function custom_bp_get_activity_css_class( $classes ){ return $classes .' '. wp_get_user_roles_by_id( bp_get_activity_user_id() ); } add_filter('bp_get_activity_css_class', 'custom_bp_get_activity_css_class');
Best Regards,
WPMU DEVThanks for the reply.
Do I need to edit the code in the functions.php for the user role Approved ?
Debbie
Yes just do it as i have described in my previous reply.
Sorry, I didn’t make myself clear
I added the supplied code above to style.css and functions.php but there was no change.
So do I need to change anything in the supplied code to point to identify the user roles I want to highlight ie “approved”
Thanks,
DebbieHi Debbie,
Sorry for any confusion.
You have to change the subscriber role in the following added CSS code with the custom role name of “Approved Member” role.
#activity-stream .activity_update.subscriber { background-color: #eaeaea; }
Please note you have to use user role name in the above code and not display name currently that is “Approved Member”. See the following page for more information on it.
http://codex.wordpress.org/Function_Reference/add_role
Your CSS code should be something like following.
#activity-stream .activity_update.approved_member{ background-color: #eaeaea; }
Please advise if you have more questions.
Regards,
WPMU DEVI’m sorry, I am still struggling to get this to work, as it doesn’t seem to be picking up the new css class?
Do you think it could be a theme conflict or have I missed something?
http://www.yourtransformation.com/activity-2/ and the approved member I am testing with is JRF
Thanks again
Hi Debbie,
Thank you for sharing the page link.
I checked your site and found you have space between approved and member words and not the underscore( _ ) that we have assumed. Also the activity_update class is not getting added to the activity so we will use activity-item class instead of it.
The following CSS code will work for you.
#activity-stream .activity-item.approved.member { background-color: #eaeaea; }
Best Regards,
WPMU DEVBrilliant, that worked great, Thanks π
I have now been asked is there anyway to add approved after their username in the Activity stream?
You are most welcome.. π
I have now been asked is there anyway to add approved after their username in the Activity stream?
The approved and member words are already added to the Activity stream on your site as CSS classes for the activities created by the user having role as “Approved Member”.
Please advise.
Sorry I should have explained better
In the link I gave earlier the member JRF is using the user role of Approved Member.
Is there a way of displaying the words “Approved Member” after his username in the Activity stream?
Yes you can display the words “Approved Member” after username in the Activity stream by developing custom code.
Could you please open a new thread for your new question?
This helps to prevent any confusion (for us) as I’m sure you understand.
This might also help other members looking for a similar answer. π
No problem π
Have a great day.. π
Cheers,
WPMU DEV
- The topic ‘How to make a specific user role stand out?’ is closed to new replies.