Home Support Extensions Geolocation Make geolocation as optional

Make geolocation as optional

  • Author
    Posts
  • vdrive6

    How to make geolocation field as optional instead of required?

    ihor developer

    You can try using this snippet, but please note that it’s not tested:

    add_filter(
    	'hivepress/v1/forms/listing_update',
    	function( $form ) {
    		if ( isset( $form['fields']['location'] ) ) {
    			$form['fields']['location']['required'] = false;
    		}
    
    		return $form;
    	},
    	1000
    );
    vdrive6

    thanks ihor, will try it

    vdrive6

    Marked as optional, but still required as before

    ihor developer

    You can try combining it with this snippet:

    add_filter(
    	'hivepress/v1/models/listing',
    	function( $model ) {
    		if ( isset( $model['fields']['location'] ) ) {
    			$model['fields']['location']['required'] = false;
    		}
    
    		return $model;
    	},
    	1000
    );
    nialb

    This worked for me

    
    add_filter(
    	'hivepress/v1/models/listing/attributes',
    	function( $attributes ) {
    		if ( isset( $attributes['location'] ) ) {
    			$attributes['location']['edit_field']['required'] = false;
    			$attributes['location']['edit_field']['description']='This address will be used to display your business location on Google Maps';
    		}
     
    		return $attributes;
    	},
    	1000
    );
    
    ihor developer

    Thanks for posting the solution! Setting it on the attribute level should work fine.

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.