步驟顯示 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;
}
}
即可。