Last active
December 29, 2015 20:59
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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