您不需要使用pass$value
在switch语句中,只需传递到那里$user->roles[0]
而不是$value
之后你的状况。
添加下面的代码,让我知道你对它的答案。
add_action( \'um_members_just_after_name\', \'my_members_after_user_name\', 10, 1 );
function my_members_after_user_name( $user_id ) {
$user = new WP_User( $user_id );
/*
if( $user->roles[0] == \'um_musiker\' ) {
// update_user_meta( $user_id, \'um_reihung\', \'40\' );
echo \'<i class="um-verified um-icon-checkmark-circled um-tip-s" title="Kein Status"></i>\';
}
*/
switch ( $user->roles[0] ) {
case "um_musiker":
echo \'<i class="um-verified um-icon-checkmark-circled um-tip-s" title="Kein Status"></i>\';
break;
case "um_musiker_bronze":
echo \'<i class="um-verified um-icon-checkmark-circled um-tip-s" title="Bronze Status"></i>\';
break;
case "um_musiker_silber":
echo \'<i class="um-verified um-icon-checkmark-circled um-tip-s" title="Silber Status"></i>\';
break;
}
}