I have a custom post type for service providers. Which is essentially a bio page for them. I have it set that they can only edit their own bio page, however to do this I had to grant them the ability to create their own bio page (Add New). Is there a way to remove the "Add New" ability once they have created their own page?
Limit a User to Only Create One Custom Post Type Post
5.8k views Asked by TripsLeft At
3
There are 3 answers
0
On
I use the above plugin and it works great. Another 'rough' way would be to use one of the front end posting plugins and use the conditional code below to restrict the author if they already have a custom post published...
Make a page template for the specific page where the front end posting form is and add this where appropriate...
<?php if (( 0 == count_user_posts( get_current_user_id(), "CUSTOM-POST-TYPE" ) && is_user_logged_in() && current_user_can('USER-ROLE-CAPABILITY') && !current_user_can( 'manage_options' ))) { ?>
[add the frontend form shortcode here]
<?php } ?>
You'd need to prevent them from gaining access to the back-end as well.
0
On
function post_published_limit() {
$max_posts = 3; // change this or set it as an option that you can retrieve.
$author = $post->post_author; // Post author ID.
$count = count_user_posts( $author, 'CUSTOMPOSTTYPE'); // get author post count
if ( $count > $max_posts ) {
// count too high, let's set it to draft.
$post = array('post_status' => 'draft');
wp_update_post( $post );
}
}
add_action( 'publish_CUSTOMPOSTTYPE', 'post_published_limit' );
Hope this is your answer. Accept it if this your answer.
I wonder if this plugin might be helpful to you:
http://wordpress.org/plugins/bainternet-posts-creation-limits/