Skip to content

Instantly share code, notes, and snippets.

@fritids
Forked from bordoni/functions.php
Created February 10, 2014 11:51
Show Gist options
  • Save fritids/8914516 to your computer and use it in GitHub Desktop.
Save fritids/8914516 to your computer and use it in GitHub Desktop.
<?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