だからここに契約があります..私はWordpress + bbPressをメンバーシップソフトウェア(aMember)と統合しています。
私のbbPressフォーラムでは、人々のユーザー名の下に、すべてのメンバーのWordpressの役割(bbpressの役割ではない)と、すべてのメンバーの役割に応じた画像を表示したいと考えています。
例えば、
ユーザー ロールがサブスクライバーの場合 -> bbpress でユーザー名の下にロールを表示 -> 下の画像も表示します。
Wordpress の役割 (bbpress の役割の代わりに) を表示したい理由は、メンバーシップ ソフトウェア (amember) で、ユーザーのサブスクリプションに応じて異なる wordpress の役割を設定できるためです。私のサイトには 2 つの異なるメンバーシップ プラン (無料と有料) があり、プランに基づいて bbpress フォーラムに異なる画像を表示したいと考えています。
bbPress テンプレートを調べたところ、次のコードが見つかりました (loop-single-reply.php 内):
<?php bbp_reply_author_link( array( 'sep' => '<br />', 'show_role' => true ) ); ?> // this shows the bbpress role
<?php echo 'Points: '.cp_getPoints(bbp_get_reply_author_id()); ?> // this shows the member points below the username - I use a points plugin)
このコードを、すべてのユーザーの Wordpress の役割 (bbpress ではない) を示すコードに置き換え、役割に応じてその下に画像を表示するにはどうすればよいでしょうか。例えば:
役割が「サブスクライバー」の場合 -> 役割とその下の画像を表示
役割が「寄稿者」の場合 -> 役割とその下の画像を表示
役割が「管理者」の場合 -> 役割とその下の画像を表示
私はプログラマーではないので、これを達成する方法がわかりません。助けてください。これを機能させるために使用できると思われる関連コードをいくつか見つけました。
<?php if ( current_user_can('contributor') ) : ?>
Content
<?php endif; ?>
失敗した試みは次のようになります。
<?php
$user_roles = $current_user->roles;
$current_user = $bbp_get_reply_author_id; // i think this is wrong :P
$user_role = array_shift($user_roles);
?>
<?php if ($user_role == 'administrator') : ?>
Show Role
Show Image
<?php elseif ($user_role == 'editor') : ?>
Show Role
Show Editor Image
<?php elseif ($user_role == 'author') : ?>
Show Role
Show Author Image
<?php elseif ($user_role == 'contributor') : ?>
Show Role
Show Contributor Image
<?php elseif ($user_role == 'subscriber') : ?>
Show Role
Show Subscriber Image
<?php else : ?>
Show Role
<?php endif ?>
何をしているのかわかりません...上記のコードは、Googleで見つけたものです。
誰でも助けることができますか?
とても感謝しております。