Make location required in only 2 categories

Actually I’m using this php code to make location not required when creating listing:

add_filter(
	'hivepress/v1/models/listing',
	function( $model ) {
		$model['fields']['location']['required']  = false;

		return $model;
	},
	1000
);

There is some php code to select in where categories location will be required?

Please try this PHP snippet and please replace 1,2,3 with categories ids

add_filter(
	'hivepress/v1/models/listing/attributes',
	function( $attributes ) {
		if ( isset( $attributes['location'] ) ) {
			$categories = [ 1, 2, 3 ];

			$attributes['location']['categories']  = $categories;
			$attributes['latitude']['categories']  = $categories;
			$attributes['longitude']['categories'] = $categories;
		}

		return $attributes;
	},
	1000
);

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.