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

  • 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
  • Things I’ve Learned Using Flywheel Local
  • Making an Easy Mistake with the gatsby-source-wordpress Plugin

Recent Comments

    Archives

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

    Categories

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