Reply To: Display Role as part of Profile
Thanks Shane
Sorry – I am a real novice here ask you to indulge me.
I have tried this inside the code you already gave me but it does not work. I guess I don’t know the correct syntax for the If statement, or I do not know how to name the role. E.g. I want to exclude bbp_spectator so tried this:
function dlongm_show_role() {
$user = get_userdata( bp_displayed_user_id() );
if ( !empty( $user->roles ) && is_array( $user->roles ) ) {
foreach ( $user->roles as $role )
if ( $role != bbp_spectator) {
echo "$role;
}
}
}
add_action( 'bp_before_member_header_meta', 'dlongm_show_role' );
I guess what puzzles me is that the array has clearly got something like this in it:
adminstratorbbp_spectator
All I need is the first element of this string or object. I am just not clear about PHP syntax to know how to get it ….
I appreciate your advice.