[wp-hackers] Partial admin capabilities

Michael D Adams mda at blogwaffe.com
Wed Jul 28 20:40:27 UTC 2010


On Wed, Jul 28, 2010 at 1:26 PM, Ryan Bilesky <rbilesky at gmail.com> wrote:
> Perfect, I tested it and it is now working.
>
> http://pastebin.com/0VnVgktV

On Wed, Jul 28, 2010 at 1:07 PM, Michael D Adams <mda at blogwaffe.com> wrote:
> 3. The cap you want is passed as the first element of the third
> parameter, not the second parameter.  The second parameter is an array
> of capabilities WordPress has decided the user must have for the
> current_user_can() or has_cap() check to pass.

In your pastebin you have: $allcaps[$cap[0]] = true; (and
$allcaps[$cap[0]] = false;).

The second parameter passed to the filter ($cap in your code) can be
an array of most anything, especially if other plugins get into the
mix.

So $cap[0] isn't guaranteed to be the cap you're looking for.  Stick
to $args[0] as you did in the switch.


More information about the wp-hackers mailing list