How Can We Help?
There is no built-in functionality at this point, but it should be possible using a custom filter function on the user_has_cap hook. The following code (add to your theme’s functions.php file) will count the number of published posts of a certain type by a specific user and remove the permission to add new posts for the specific post type if the user has already published a post.
Note: You need to change the ‘directory_dir_ltg’ part to the post type of your directory listing. The post type name is viewable from:
Directories –> [Your Directory] –> Content Types.
add_filter('user_has_cap', function($allcaps, $cap, $args) { // Some initializations $post_type = 'directory_dir_ltg'; $cap_to_check = 'drts_entity_create_' . $post_type; $limit = 1; // Bail out if this is not the capability we are looking for if ($cap[0] !== $cap_to_check) { return $allcaps; } // Bail out if the current user doesn't have the capability currently if (!isset($allcaps[$cap_to_check])) { return $allcaps; } // Bail out if the number of posts by the current user is below the limit if (count_user_posts($args[1], $post_type) < $limit) { return $allcaps; } // Remove the capability unset($allcaps[$cap_to_check]); return $allcaps; }, 10, 3);