I have a site that offers non-paying members up to 5 posts using this:
function author_post_count($user_id, $post_type = array('YOUR_CUSTOM_POST_TYPE_NAME_HERE')) {
$args = array(
'post_type' => $post_type,
'author' => $user_id,
'posts_per_page' => -1
);
$query = new WP_Query($args);
return $query->found_posts;
}
Then I use:
if ( author_post_count(get_current_user_id()) >5) {
SHOW RESTRICTION NOTICE CODE HERE FOR USERS WITH MORE THAN 5 POSTS
}
So you could use those two together and then the save_post
hook.
If you’re not familiar, read up on it and in particular this part about avoiding a loop: https://developer.wordpress.org/reference/hooks/save_post/#avoiding-infinite-loops
Then you could change the query to use Date Parameters
Related Posts:
- Multiple authors for single post without plugin
- (solved) getting post author’s user role
- Hook that get’s triggered when the author of a post is changed
- Allow user to “edit_others_posts” to save only, not publish
- Prevent Authors from viewing each others Posts
- Display Random Author with Details in Sidebar
- WordPress: How to get the current logged in author page URL?
- How to add editor’s name to entry meta byline?
- How to limit user to publish post per day and per role?
- Query posts distinct authors
- Restrict the Number of Posts an Author can Publish (over time)?
- Get the user type of an author
- Show the title of the latest post by author
- Remove Posts Quick Edit link for specific user role? WP 3.3
- Get current users post URL?
- Filter posts by author and category simultaneously
- Custom Post Type & Author not associating, user post count is 0, api doesn’t return author in post objects
- Guest Author – How to modify my custom function code if the guest author URL will follow a particular pattern/format?
- Post author is changed to admin after his post is modified by admin
- Get all posts by post_author
- Allow role to delete posts but block him the wp-admin
- How can I control multiple editing of wordpress posts?
- If specific user role then sticky post
- Show the author’s count of total amount of posts assign to a custom taxonomy term
- Author must complete profile info before they can publish a post?
- WP rest api returns 404 only when author param is used
- How can I list random authors from current post category?
- Remove the Edit button in posts for permalinks on certain user roles? WP 3.3
- How can I show wordpress posts based on author?
- Show info to author only
- Limit posts per author role (excluding admin) in home page
- Guest Author – How to display posts on /author/ archive page
- How to give capability (publish contributors posts) to author role?
- Update a users role based on number of posts published
- Show posts by a custom post author
- How to allow users to post only in certain category and hide elements from edit page?
- Getting the current author (it has changed) of a post, not the original author
- Post visibility based on user role
- “edit_published_posts” and “edit_other_post” issue
- User levels and post visibility
- Showing author page if user has no post
- Display Notification Bar on Header on Certain Post Count
- How do I retrieve a users’ last 5 posts?
- obtain the author id given the post id
- Show comment number per author per day
- Get all comments of author’s posts
- Show posts by author of membership level (Paid Membership Pro)
- Hide comments and posts posted by other user
- static landing page leading to author specific pages w/ “live” content
- If contributor has published 2 or more posts then show otherwise hide
- All Posts Linking to Author Posts directly
- Change post author without using wp_update_post()
- How to get the ability to change the author of a post
- Echo Text If User Is Logged in But NOT the Author of post
- Only allow posts with a specific term to only be viewed by other authors with the same term in their post
- How to limit author related post listing ?
- Restrict displaying posts to the poster itself (in Back-end)
- Get total post from an author
- Send email to author of post on post submission
- How can I set a maximum allowed post size and number of posts submitted?
- Get x recent posts by author?
- Get latest author posts inside the loop
- Author Avatar as default first image
- Cannot select certain authors for posts after import
- Display message depending on capability outside loop
- How do I disable the “by author” hyperlink on posts?
- Authors’ Links on Homepage Not Going to Author Post Pages
- adding my posts (author posts) in menu
- Prevent 404 of Author pages without posts
- how to show comments only author which send own posts in wordpress
- Restricting displayed posts to posts from only select authors
- Author post count in category
- Change of author not updating
- Administrator Posts
- On WordPress Search, how to search post from Author meta also
- allow editor/author to publish others posts but not publish their own
- Changing a users posts to drafts upon role change
- How to hide meta from search result only on pages?
- Numbering author posts in posts query
- Allow author to duplicate but not edit post
- Custom author search
- Add new post only in assigned category
- Changing the Category for all posts of an Author
- List of authors posts minus very latest
- Remove All in One Seo from Posts for Contributors
- show latest authors blog post
- Admin Post List Only Show One Category
- Getting posts from multiple users?
- Display the current post author and his url in the post header
- Set the limit to allow author when make post!
- Show last post of employee in his profile page
- each user having category with their name and can add sub categories post in that category
- WordPress strips some attributes for author posts
- Notify Author of the post if admin deletes his post and perform some function
- how to show all type of author posts in author page (SOLVED)
- How to show total view count across all posts for an author
- How can I add Author’s phone number to wp profile and make it appear in wp-admin/edit.php columns
- Add author section on Author archive posts
- How to make the Post Author name fixed as “Editorial Staff” even if there are multiple authors?
- Display posts with id equal to relationship value