Skip to content

Instantly share code, notes, and snippets.

@bordoni
Last active December 29, 2015 20:59
Show Gist options
  • Save bordoni/7727022 to your computer and use it in GitHub Desktop.
Save bordoni/7727022 to your computer and use it in GitHub Desktop.
Limita a edição de posts para colaboradores que não tenham posts publicados.
<?php
add_filter( 'user_has_cap', function($all, $caps, $args, $user){
if (!in_array('contributor', $user->roles))
return $all;
$posts = get_posts(array(
'post_type' => 'post',
'post_status' => 'publish',
'posts_per_page' => 1,
'author' => $user->ID,
));
if (count($posts)>1)
unset($all['edit_posts']);
return $all;
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment