Restricting booking to 'Verified' Category and Hiding that Category from the Front End

If I created a ‘Verified’ Category - for those who pay can have the Booking Feature.

  1. Can I hide that ‘verified’ category from the front end so they cannot simply choose it.
    That I would choose it upon receiving the notification of the listing and I note payment for it?

  2. Is it best to be a Listing Category or Vendor Category?

Many thanks

Hi,

Unfortunately, there is no easy way to hide some categories and leave some, it will require advanced customization. If customizations are required for your site, please try customizing it using the collection of code snippets Search · user:hivepress · GitHub and other developer resources, or consider hiring someone for custom work Experts | HivePress

As Booking extension appears in the settings to only be limited by Category. It feels I have to work with a Category and as I want Bookings to be a paid for option and not free for everyone.

Therefore it appears I have to work with a singular category. So unless I have misunderstood the current function of bookings within the theme and you advise any other way to achieve this within the current settings?

If not, the only options I have open to me, is calling the Category something obscure like ***, that would not make sense to the front end user? Otherwise, I will look at the snippet codes in GitHub and see what needs to be amended to achieve hiding this category from the front end. Thank you

  1. To hide a category from the front end (When Adding a Listing), this code works from Yehven, thank you! (Replace 1,2 ,3 with your chosen category ID’s)

add_filter(
	'hivepress/v1/models/listing/fields',
	function($fields, $model){
		$disabled_categories_ids = [1,2,3];
		
		if(isset($fields['categories']['options'])){
			foreach($disabled_categories_ids as $category_id){
				unset($fields['categories']['options'][$category_id]);
			}	
		}
		
		return $fields;
	},
	10000,
	2
);

Also, if you need to hide a category from other category drop down areas, from within your site: I found this code ‘using category name’ (its text label) snippet worked for me; (Replace Category Name with your Text Label/Category Name):


add_action('wp_footer', function() {
    ?>
    <script type="text/javascript">
        document.addEventListener('DOMContentLoaded', function() {
            // Target the category by its text label instead of ID
            
            // For dropdowns
            var categoryOptions = document.querySelectorAll('option');
            categoryOptions.forEach(function(option) {
                if (option.textContent.includes("Category Name")) {
                    option.remove(); // Remove the option
                }
            });

            // For checkboxes (if categories are shown as checkboxes)
            var categoryCheckboxes = document.querySelectorAll('label');
            categoryCheckboxes.forEach(function(label) {
                if (label.textContent.includes("Category Name")) {
                    label.style.display = 'none'; // Hide the checkbox
                }
            });
        });
    </script>
    <?php
});