步骤显示wp_users角色,不包括bbpress默认角色
1)首先在你的子主题中创建一个名为 wp-content/theme/yourchildtheme/bbpress 的文件夹。
2)然后从 wp-content\plugins\bbpress\templates\default\bbpress 复制文件 loop-single-reply.php
3)转到第47行并该行
bbp_reply_author_link( array( ‘sep’ => ‘<br />’, ‘show_role’ => false ) );
替换为
bbp_reply_author_link( array( ‘sep’ => ‘<br />’, ‘show_role’ => false ) );
$reply_author_id = get_post_field( ‘post_author’, bbp_get_reply_id() );
$user = new WP_User( $reply_author_id ); if ( !empty( $user->roles ) && is_array( $user->roles ) )
{
foreach ( $user->roles as $role )
{
/*if (preg_match(“/”.$roles.”/i”, “administrator”))
{
echo(“Administrator”);
break;
}
else*/
echo “<div class=’role_custom_bhush’>”.ucfirst($role).”</div>”;
break;
}
}
即可。