1

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

2

author_can() seems to fit.

Example:

if( author_can( get_the_ID(), 'administrator' ) ) 
  • 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 clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy