## (solved) getting post author’s user role

Question

we can use

$user = wp_get_current_user(); if ( !in_array( 'administrator', (array)$user->roles ) )


to get the user role of the viewer. but i want to ignore who views. i want to get who writes the post. need something like

$user = wp_get_post_author(); if ( !in_array( 'administrator', (array)$user->roles ) )


so that i can show results depending on the user who writes the post while ignoring who views that.

0
2 years 2020-12-21T22:10:42-05:00 0 Answers 3 views 0