You can use count_user_posts function.
If the posts are getting saved as WordPress posts then it can be done by the snippet below:
if (is_user_logged_in()){
$userPostCount = count_user_posts(get_current_user_id());
if ($userPostCount > 1){
$user = new WP_User(get_current_user_id());
$user->add_cap('publish_posts',false);
} else {
$user->add_cap('publish_posts',true);
}
}
Related Posts:
- Different number of posts in each category
- How to limit user to publish post per day and per role?
- Restrict users from editing post based on the age of the post
- Restrict access to post if it is currently being edited
- WP_Query posts_per_page ignored
- Limiting the number of posts in WP_Query leads to unexpected result
- Limit posts per author role (excluding admin) in home page
- Restrict users post for himself
- How to limit posts by category
- How can i limit the number of posts created per category?
- Increase 10 post limit per page
- query post limits
- Custom Post Limit for homepage only without plugin?
- I want to show my post for limited time, how is it possible?
- How can I set a maximum allowed post size and number of posts submitted?
- Setting limit to posts or page creation
- How to limit post (Exception pages) for current user in each role in front end?
- Limit front-end submitted posts by role
- numberposts not working
- How Can I Limit Users to Post Creation For My Frontend Theme?
- How to limit the number of results for all query_posts on mysite
- Set the limit to allow author when make post!
- limit posts per page
- wp trim function not working
- How to end the excerpt with a sentence rather than a word?
- How to automatically generate a unique random slug
- How does filter the_posts work?
- SQL Query for getting all posts in their latest revised state
- Publish pending article from front end with a button?
- How can I export WordPress posts’ attachments?
- Restrict the Number of Posts an Author can Publish (over time)?
- How do I convert a mathematical Microsoft Word document to a WordPress blog post?
- Which file displays the date archive?
- Add custom field to category of custom post type
- Change post format using custom field
- Plugin for sortable posts in grid [closed]
- How can I make existing custom fields easier to edit/add in my theme?
- Display Latest Post from all Categories
- WordPress theme ajax have_posts()
- Easy way to delete 70k posts and attached media?
- wp_insert_post works, but the post isn’t visible in the admin post list or front end
- Remove arrows from previous and next link
- XML-RPC and post_date
- wp_tag_cloud() and the_taxonomies() work but not the_tag()
- Split WordPress Latest Posts in Multiple Columns and Rows with one single loop [closed]
- How to display data in archive page?
- Drag posts and pages so you can sort them in order
- Category Foreach keeps looping?
- CPT archive redirects to single post
- Archiving by academic year instead of calendar year
- Posts will not display on page-mypage.php
- display a random post thumbnail from a random category
- Display News Posts by Day with Post Counter
- Duplicate Custom Post Type and Taxonomy Slug
- How we exclude current post form related posts
- Remove Content after
- Is there a way to add the list of recent posts into the admin sub menu on hover?
- Replace image name on upload to the new post name on front-end form
- Need to change all links in page content but not in post content
- linking to post outside the loop
- wordpress post not showing my “” text>?
- Sort All Posts by Category Name in the Admin Panel?
- Help with listing current users submitted custom post type in template file
- Trying to query all posts in category 4
- Create a frontpage.php and static page template
- How to create several Post pages
- How to show next/prev link, when it’s not active?
- Grab value of excerpt_length
- Can I restore restore content from old Worpress site to a new Worpress site from an archive
- Changing The Default Header POST Title and Description text by category in wordpress
- Display hierarchical categories/sub-categories for a single post only
- Is it possible to modify posts table to only read for more recent ones?
- blog post not accesible on click [closed]
- Display Post from Custom Post Type with Shortcode
- Using a meta_value or postdate to to query and orderby
- Exclude posts in home slider from sections
- Display images of related posts
- How to generate an HTML link automatically from URL in a users’ post
- How can I get the last post while on the first post for pagination? As if it were infinite
- New blog post published notification – Buddypress
- Custom post styling per category?
- What is the difference between options and custom fields (meta) in WordPress?
- Shortcode: How to add custom posts?
- Meta boxes not saving
- problem with creating a wordpress post slider
- Post Publish Metaxbox on a Front End Page
- Hide first blog post in content and output it in widget
- Allow users to create their own page/s
- custom single.php post showing up twice
- How to use extract shortcode in loop?
- Make division in post_query?
- making a few sites in wordpress
- Simple method to generate posts from files
- WordPress posts loop pagination – first page return 125 posts instead of 10 and the rest return 10
- clicking on page title
- change page name on page list
- append $_GET parameters to post
- Undefined Function Fatal Error with Shortcode [closed]
- I have a website issue I am trying to resolve
- How to sort posts alphabetically based on a specific parent category