Bypass listing moderation if vendor has at least one listing

I want to revisit this topic: No listing approval for approved/verified vendors

When the registered user has their first listing approved, their Wordpress user role changes to Contributor.

Based on that role change, it should be possible to also change their listings to no longer require approval.

Can Hivepress make this possible, or, at the very least, help me with the information needed so I can implement this, for example with a code snippet?

Update: I have tried using the User Role Editor plugin to give the Contributor role the 'publish_post’ permission for Listings, but the Listings I made to test still end up pending approval.

Hi,

It doesn’t check the capabilities of a contributor, this role is simply assigned because it’s the minimum required for WordPress to allow assigning authors to content.

Also, thank you for the feature suggestion, we’ll consider implementing it. For now, please try the following code snippet. Please note that it does not bypass the “Listing Submitted” page. As a workaround, you can update the text on that page to something like: If you already have published listings, your new listing will be published automatically. If this is your first listing, it will be reviewed shortly.

add_action('hivepress/v1/models/listing/update_status', function($listing_id, $new_status, $old_status, $listing) {
    if ($new_status !== 'pending') {
        return;
    }
    
    $vendor = $listing->get_vendor();
    
    if (!$vendor) {
        return;
    }
    
    $listing_count = \HivePress\Models\Listing::query()->filter([
        'vendor' => $vendor->get_id(),
        'status' => 'publish',
    ])->get_count();
    
    if ($listing_count >= 1) {
        $listing->set_status('publish')->save_status();
    }
}, 1000, 4);

Alternatively, you can further customize this snippet yourself or reach out to freelancers for more advanced adjustments.

Thank you for that - it worked!

Yes, I think this would be a valuable option to add to the Hivepress → Vendor settings, and it seems like it would be fairly simple to implement as well.

1 Like

Glad to help! :herb:

If you have a minute, please rate HivePress on the WordPress repository or Trustpilot. Your feedback means a lot to us and makes a real difference in helping us grow.