使用global $authordata
:
角色测试:
global $authordata;
if ( in_array( \'administrator\', $authordata->roles ) )
{
echo \'Hello Admin!\';
}
elseif ( in_array( \'editor\', $authordata->roles ) )
{
// echo something else
}
或功能测试:
if ( ! empty ( $authordata->allcaps[\'manage_options\'] ) )
{
echo \'The author can manage options\';
}
elseif ( ! empty ( $authordata->allcaps[\'edit_others_posts\'] ) )
{
// echo something else
}