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
Abdullah Al Muaz 1 month 0 Answers 8 views 0

Leave an answer