[wp-hackers] Cannot figure this out: user_has_cap

Dino Termini dino at duechiacchiere.it
Mon Jun 2 16:55:14 UTC 2014


THANK YOU!!! :) I was indeed logged in as a super admin on mu :/

On 6/2/14, 12:52 PM, John Blackbourn wrote:
> Are you logged in as a super admin on multisite? The user_has_cap filter
> doesn't get called in that situation.
>
> My User Switching plugin has a nice bit of documentation with its callback
> functions for this filter and the corresponding map_meta_cap filter, which
> may help you. See here and here:
>
> https://github.com/johnbillion/user-switching/blob/0.8.8/user-switching.php#L36-L37
> https://github.com/johnbillion/user-switching/blob/0.8.8/user-switching.php#L533-L576
>
> John
>
>
> On 2 June 2014 17:26, Dino Termini <dino at duechiacchiere.it> wrote:
>
>> Hi list,
>>
>> For the life of me, I can't figure this out. I want to prevent my authors
>> to edit a bunch of pages on my website.
>>
>> Aside from using pre_get_posts to change wp_query, I'd also tweak
>> current_user_can "on the fly" and remove "edit_pages" from the user's
>> capabilities, if the ID is in my blacklist.
>>
>> So I created a plugin with the following code:
>>
>> function tweak_edit_page_capability( $allcaps, $caps, $args ) {
>>      file_put_contents( '/file/somewhere', 'it works!', FILE_APPEND );
>>      return $allcaps;
>> }
>> add_filter( 'user_has_cap', 'tweak_edit_page_capability', 10, 3 );
>>
>> However the function is not called! What am I doing wrong? I've
>> deactivated all plugins and reset the theme, but nothing helps!
>>
>> Dino.
>> _______________________________________________
>> wp-hackers mailing list
>> wp-hackers at lists.automattic.com
>> http://lists.automattic.com/mailman/listinfo/wp-hackers
>>
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers



More information about the wp-hackers mailing list