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.

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
add comment

1 Answer

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
1  
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
add comment

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.