Created
July 13, 2016 13:08
-
-
Save JudeRosario/a3babb91cb3d9a0f36c809c8ab11c91f to your computer and use it in GitHub Desktop.
Apply CSS to users avatars by role
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
add_filter('bp_member_avatar', 'bp_role_in_class'); | |
function bp_role_in_class( $args ) { | |
global $members_template ; | |
$user = new WP_User( $members_template->member->id ); | |
if ( !empty( $user->roles ) && is_array( $user->roles ) ) { | |
foreach ( $user->roles as $role ) | |
$args['class'] .= " " . $role; | |
} | |
return $args; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Please update this to reflect Panos' snippet in this thread: https://premium.wpmudev.org/forums/topic/buddypress-apply-css-to-users-avatars-by-role