Skip to content

WP Developing

Learning WP Development My Way

Tag: user submitted content

Can one report reviews in Directories Pro?

While this functionality is available in Sabai Directory, it is not currently available in Directories Pro.

Is it possible to limit the number of frontend submissions to one per user?

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);

Can a user create multiple reviews for a single listing?

Currently, yes.

Can any user post new listings?

Depends on the permissions you have defined.

Recent Posts

  • Things You Almost Certainly Will Never Need to Know: WDS-Shortcodes
  • DevKinsta: Initial Thoughts and Feedback
  • Migrating a WordPress Site to SpinupWP the Easy Way
  • When You Get an Invalid Default Value Error While Changing Your MySQL Engine on a Table from MyISAM to InnoDB
  • Headless WordPress

Recent Comments

  • phg3a on Things I’ve Learned Using Flywheel Local
  • Ben on Things I’ve Learned Using Flywheel Local

Archives

  • May 2021
  • April 2021
  • November 2020
  • September 2020
  • May 2020
  • April 2020
  • September 2018

Categories

  • Database
  • Developer Knowledge
  • Developer Tooling
  • Directories Pro
  • Gatsby
  • Hosting
  • MySQL
  • Plugins
  • SQL
WP Developing Proudly powered by WordPress