I would have to give this a +1! Don’t you just love hacks?
it would probably require some heavy data collecting if you want it to be just that specific group. Especially if you have a-lot of mods or admins
Hacks??? are we breaking rules?
Check out /buddypress/bp-groups/bp-groups-templatetags.php.
In particular, here are the conditional functions you’re looking for:
`bp_group_is_admin(); // will return true if the user is a group admin
bp_group_is_mod(); // will return true if the user is a group mod`
Use in a conditional statement and you’re good to go!
eg.
`if ( bp_group_is_mod() ) echo ‘Group Moderator’;`
Thanks r-a-y. So I stick the second code where I want the text to appear right?
The first code I am totally lost.
Yeah, the second code; I was just trying to explain where you can find useful functions for groups
Try it!
Be sure to wrap it around php tags though.
“
@r-a-y, I put the second code below the
“
but nothing appears..
Sorry about that! I thought it would work. Looks like BP is missing some template tags for this.
This will work.
Add the following to your theme’s functions.php:
`
function bp_topic_poster_is_admin() {
global $topic_template;
return BP_Groups_Member::check_is_admin( $topic_template->post->poster_id, bp_get_the_topic_object_id() );
}
function bp_topic_poster_is_mod() {
global $topic_template;
return BP_Groups_Member::check_is_mod( $topic_template->post->poster_id, bp_get_the_topic_object_id() );
}`
Then use this in your template:
`if ( function_exists( ‘bp_topic_poster_is_mod’ ) ) :
if ( bp_topic_poster_is_mod() ) echo ‘Group Moderator’;
endif;`
Awesome! now if I could just style it enough to show up under the avatar…
@r-a-y, I found a little incompatibility with your code, and with The “bp unread posts” plugin, it seems that this code is making it not to appear
`function bp_unread_posts_record_activity() {
global $bp;
global $forum_template;
if ( bp_has_forum_topic_posts() ) $bb_this_thread = $forum_template->topic->topic_id;
if (empty($bb_this_thread)) {
return $null;
}
$bbtype = ‘last_visits_user_’;
$bbuser = $bp->loggedin_user->id;
$bb_this_visit_time = strtotime($forum_template->topic->topic_time);
$bb_last_visit = bb_get_topicmeta($bb_this_thread, $bbtype . $bbuser);
if($bb_last_visit != $bb_this_visit_time) {
bb_update_topicmeta($bb_this_thread, $bbtype . $bbuser, $bb_this_visit_time);
}
}`
what is making it not appear?
Im thinking it is this line: `if ( bp_has_forum_topic_posts() ) $bb_this_thread = $forum_template->topic->topic_id;`
Not sure. I haven’t used the BP Unread Posts plugin before, but if that plugin modifies the $topic_template global, then it will probably interfere with the code.
is there a way around it? I would love both
This code pretty much does exactly what I want, which is to display the user’s role/level in forums. I got it to work for Admin and Mod, but I’m a code idiot so I’m not sure how to get it to work with other levels? I’m using s2Member so I have levels that are written to BP/WP users like Working Student, Auditing Student, Free Subscriber, etc.
Tips?
TIA,
Daisy
I can’t get this to work, I added those functions to the functions.php file and put in the if statement, but it doesn’t detect whether they are a moderator or not.
Any idea whats up?