I'm creating a page in my wordpress site, with a list of the users and need to get the title of their role with php. But, every thing I tried failed. Anyone who can help please.
1条回答 默认 最新
duanfenhui5511 2016-05-23 08:50关注The function that returns the current user roles :
function display_user_roles(){ $user_id = get_current_user_id(); $user_info = get_userdata( $user_id ); $user_roles = implode(', ', $user_info->roles); return $user_roles; }To use it in your code:
<?php echo display_user_roles(); ?>本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报