Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Example :- 10 users and 2 admin in a site.

If the post is published by admins than

<?php ?????() { ?>
  <!-- do this -->   
  <?php } 
  else { ?>
   <!-- do this if posted by user --> 
  <?php } ?>
share|improve this question
    
When do you want this to work? When a user is logged in and publishes a post OR a post is already published and you wan to check the author? –  Rutwick Gangurde Jul 3 '12 at 11:53
4  
Please, don't cross-post... stackoverflow.com/q/11310023/1287812 –  brasofilo Jul 3 '12 at 12:13
    
+1 for @brasofilo 's suggestion. –  Rutwick Gangurde Jul 3 '12 at 12:19
    
If is post/page is not published by admin than show the User/Author name. If the post is published by Admin than not to show anything. –  Tamal Dey Jul 4 '12 at 7:46

1 Answer 1

up vote 2 down vote accepted

This could be simple as:

global $post;
if ( user_can( $post->post_author, 'manage_options' )){
    // this is an admin
} else {
    // this is not
}

Assuming the only admins on your site can manage options.

share|improve this answer
    
If is post/page is not published by admin than show the User/Author name to any visitor (Not necessary it has to be a logged in user). If the post is published by Admin than not to show anything. And their are many user in the site in which 2 admins, 4 editor and other are contributes. Thanks for the help +Bainternet & +Kaiser –  Tamal Dey Jul 4 '12 at 7:55

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.