所以这是交易..我将 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 ?>
我不知道我在做什么......上面的代码是我在谷歌上找到的。
任何人都可以帮忙吗?
我真的很感激。