WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need a function that returns true when the author is an admin or an editor or of a certain role.

I can't use is_single because I have set up a forum and there are a million singles out there and I need a different layout for THE posts (the ones written in the blog by admins and editors) than from the forum entries

share|improve this question
up vote 2 down vote accepted

author_can() seems to fit.


if( author_can( get_the_ID(), 'administrator' ) ) 
share|improve this answer
Yes it does, thanks a lot! – Lisandro Dec 11 '10 at 22:01
Could you give me an example of how to use it? Thanks – Lisandro Dec 11 '10 at 22:06
Added example. I think docs cover function quite well, anything in particular you have trouble with? – Rarst Dec 11 '10 at 22:16
Thanks, I tried it and it worked. I have just one question, how do I add a second role so that it triggers then too? like for example editor. – Lisandro Dec 11 '10 at 23:37
Make two checks and join them with PHP or operator - ||. This is more of PHP basics than WP. – Rarst Dec 11 '10 at 23:40

Your Answer


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