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

According to Codex we can perform current_user_can checks for certain post_ID, but I fail to find any bit of info how to set a capability explicitly for that post_ID.

A follow up question - how to set custom capability (for ex. download_doc) of the same type that could be later checked by current_user_can( "download_doc", get_the_ID() );

share|improve this question
Refer this answer wordpress.stackexchange.com/questions/35165/… – Vinod Dalvi Apr 15 '13 at 10:58
This is really two questions, you should separate them into two posts for clarity and so that the best answer for each can be clear. – jeremyclarke Aug 13 '14 at 15:03
up vote 1 down vote accepted

As far as I know, you can not (easily) set up a custom capability for a certain post/page ID. What is described in the Codex, are the so-called meta capabilities (a set of predefined capabilities with additional arguments/information).

A (not-that-easy) way is to write your own my_add_cap, my_current_user_can, my_has_cap etc. functions.

Regarding your follow-up question...
You could choose to not add/check the capability download_doc with an ID as argument, but the unique ID-based capability download_doc_{$ID} instead.

share|improve this answer
Thanks, that's how I do it currently. Didn't know about the meta caps and implementing something like these is probably overkill. – Zlatev Apr 15 '13 at 11:27

Your Answer


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.