- This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
Viewing 2 posts - 1 through 2 (of 2 total)
- The forum ‘Back End’ is closed to new topics and replies.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
Hello,
I have this code. It is supposed to display the text “Staff” if a user can edit posts, or display the current WordPress user role if not. An example of this would be
Austin: Staff.
Billy: Premium Member.
Joe: Basic Member.
This code translates the BBPress roles to WordPress roles so it makes more since to users. The only problem with this code is it adds a < in front of the user roles, could you please check the code for syntax errors? The Staff label is working fine.
/*Display staff and user role label on BBPress*/
add_action ( 'bbp_theme_before_reply_author_admin_details', 'wpmu_staff_label' );
function wpmu_staff_label(){
if (current_user_can('edit_posts') ) {
echo '<div class="bbp-staff-role">Staff</div>';
} else {
global $current_user;
echo '<div class="bbp-user-role">' . get_user_role_redux($current_user->ID) . '</div>';
}
}
function get_user_role_redux($user_id) {
global $wp_roles;
$roles = '';
$user = new WP_User( $user_id );
if ( !empty( $user->roles ) && is_array( $user->roles ) ) {
foreach ( $user->roles as $role ){
$roles .= '<div class="bbp-user-role">' . translate_user_role($wp_roles->roles[$role]['name']) . '</div>';
}
}
return $roles[0];
}
https://premium.wpmudev.org/forums/topic/display-staff-for-moderator-and-keymaster
Thanks.
Hello,
It turns out it was not the code doing it, please read here for a solution.
https://premium.wpmudev.org/forums/topic/display-staff-for-moderator-and-keymaster?replies=15#post-1075592
Thanks.