I search a PHP code what is show a certain text or html code on the post page when the post author is an author. (not admin or editor)
When the post author is an admin or editor then show nothing.
Thanks
I search a PHP code what is show a certain text or html code on the post page when the post author is an author. (not admin or editor)
When the post author is an admin or editor then show nothing.
Thanks
Share Improve this question asked Oct 12, 2019 at 3:40 Viktor NagyViktor Nagy 11 bronze badge 2- I'm sure what you're trying to ask for? It would be more better if you could add more explanation or some code that you've tried so far. If you're intent to ask that on front end post page is visited by author of the post and he can show some special extra peace of lines or HTML! – Vantiya Commented Oct 12, 2019 at 4:10
- I search a PHP code: If the post author is from specific user role, (author) then show something... Else do not show anything. – Viktor Nagy Commented Oct 12, 2019 at 4:38
1 Answer
Reset to default 0This code will do it:
global $post;
$user = get_user_by( 'ID', $post->post_author );
if ( in_array( 'author', $user->roles ) ) {echo "Author";}
You don't even need global $post;
if you are if a query loop.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745087795a4610509.html
评论列表(0条)