[wp-hackers] Cannot figure this out: user_has_cap

Dino Termini dino at duechiacchiere.it
Mon Jun 2 16:26:05 UTC 2014


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.


More information about the wp-hackers mailing list