Here a code example with explanation in the comments:
// First a check whether the use is logged in or not:
if ( is_user_logged_in() ) {
// The user is logged, retrieve the user id
$user_ID = get_current_user_id();
// Now we have got the user's id, we can pass it to the function 'count_user_posts':
echo 'Number of posts published by user: ' . count_user_posts( $user_ID );
} else {
// The user is not logged in
}
Related Posts:
- Gather posts into a cart/lightbox and share with another user
- Retrieve data from post meta meta_key having ‘_product_fq_image’ while having author_id and post type is PRODUCT
- How to check if post meta key exists or not in wordpress database
- Update post counts (published, draft, unattached) in admin interface
- How to add category to: ‘wp-admin/post-new.php’?
- How to Display a List of Users Who Have Made at Least 1 Post?
- Find out who deleted a page or post?
- How can I retrieve multiple get_post_meta values efficiently?
- Code to make a post sticky
- How to allow hidden custom fields to be added from wp-admin/post.php?
- Export WordPress Posts and Meta Information in CSV format
- WordPress: How to get the current logged in author page URL?
- Delete duplicated wp_postmeta record
- disable password protected page for logged users
- Will a large postmeta table slow a site down?
- Update all posts automatically when using post_meta
- How to batch update post content with custom post meta value
- Change slug with custom field
- Force “Submit to review” when a post is updated
- Better post meta efficiency?
- Setting post meta data to random value during post status transition / on publish
- Edit meta data does’t work with custom sql
- Overview with latest edited posts and pages
- Navigation link to specific user page
- Show a list of recently viewed posts to a user
- Get how many days since last post of the current user
- Human Time Diff, change mins to minutes
- Change post format using custom field
- Hide comments awaiting moderation from user who submitted the comments
- Does WP get all post_meta on POST page?
- Sanitizing `wp_editor();` Values for Database, Edit, and Display
- Query All users that has post
- Exporting Data from WordPress into a flat table
- Adding Multiple Values to a Post Meta Key
- Using radio button meta data from a custom meta box
- Limit number of posts a user can make per minute?
- How do I allow users to follow a post and then allow admins to email all users who have followed that post?
- wp_insert_post let users post to without login…broke
- Get user’s most published categories
- Allow anonymous users to post to my site for moderation
- PHP Notice error (when on 404 page)
- What Is meta_id In wp_postmeta?
- disable column on post and user list
- Checking if a post with certain meta value exists
- How to permanently delete a post meta entry?
- Add custom field automatically (add_post_meta) with value based on number of words of article
- how to find user ids of all commenters in a post
- How to list users and their post amount?
- How to generate numbers indistinguishable for the IDs of the posts
- Is there any way to allow users to access content before it’s published?
- UberMenu list current user’s posts as menu items
- Modify WP_Post before processing
- Save re-arranged draggable post items to wordpress database
- I would like to give special promotion for the first 100 posts in my blog? Can anyone tell me how to do that?
- Change post_date to post_modified date on post template?
- Create post for every user?
- count the total number of comments the user has received for his published posts
- Converting a dynamic piece of code using WordPress Loop into a static one using Post ID
- how to delete all users and posts based on ‘user_meta’?
- Restrict users post for himself
- How to allow logged in users to post anonymously
- Allow public to post on blog
- How can I sort posts by the date and a custom meta field?
- is there a way to show the the post title after the image?
- Get Meta Key Value While Saving Post
- current post with current author
- How to verify wp user password by sql query in wp? [closed]
- Force the “Choose from the most used tags” meta box section to always be expanded
- How can I get global $post to work for CPT and update user?
- Meta value does not save for scheduled posts
- Custom Posts Query and meta_query Sort Order
- How can i delay reading posing in 3days for not logined user?
- Encountering “Wrong nonce. Action prohibitied.” when trying to alter User Role and unable to Post via WP Admin
- How to compare two posts including their meta fields on a scalable base?
- Getting value from get_post_custom
- Users problem (multi-author plus multisite)
- Calling Different Custom Post Timestamps in a table
- Is it possible to paste a link without tags and make it directly a link in a post?
- Cannot retrieve a custom RSS field from posts
- Saving custom fields to a custom taxonomy
- How to automate featured posts number? [duplicate]
- How do I manage my users post before publish?
- How do I retrieve a users’ last 5 posts?
- cannot get user_registered date from get_user_meta
- Customize rel=canonical tag for single blog post
- Change all author links in Blog roll
- How to I retrieve the ID from the Posts page?
- How to save meta checkbox WordPress
- Assign published posts to another user automatically
- How to calculate the average of a post meta value(Numeric) of a specific author
- Is there any way to tell when wp_postmeta has been updated?
- Add field to user meta table in database when link is clicked
- Hide comments and posts posted by other user
- Automatically create a default set of posts for each new registered user
- wpColorPicker – problem with implementation to post meta
- Summary of Posts by an User
- Change post author without using wp_update_post()
- Display a list of users who have viewed the post you are viewing
- if in category but only with post meta
- Check if current user has a post and that post has any term/s from a specific custom taxonomy outside the loop