Function Reference: geodir_user_post_listing_count
Summary
Get user’s post listing count.
Global Values
- $wpdb
- (object) (required) WordPress Database object.
- Default: None
- $current_user
- (object) (required) Current user object.
- Default: None
- $plugin_prefix
- (string) (required) Geodirectory plugin table prefix.
- Default: None
Package
GeoDirectory
Return Values
- (array)
- User listing count for each post type.
Change Log
Since: 1.0.0
Source File
geodir_user_post_listing_count() is located in geodirectory_hooks_actions.php [Line: 2364]
Source Code
function geodir_user_post_listing_count($user_id = 0) { global $wpdb, $plugin_prefix, $current_user; if(!$user_id){ $user_id = $current_user->ID; } $all_posts = get_option('geodir_listing_link_user_dashboard'); $user_listing = array(); if ($user_id && is_array($all_posts) && !empty($all_posts)) { foreach ($all_posts as $ptype) { $total_posts = $wpdb->get_var("SELECT count( ID ) FROM " . $wpdb->prefix . "posts WHERE post_author=" . $user_id . " AND post_type='" . $ptype . "' AND ( post_status = 'publish' OR post_status = 'draft' OR post_status = 'private' OR post_status = 'pending' )"); if ($total_posts > 0) { $user_listing[$ptype] = $total_posts; } } } return $user_listing; }