Join our new community forum for support & discussion

Join Now

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.

    razorboy

    Which file did you insert this in?

    Bemay1

    On the plugin called “code snippets”

    ihor developer

    Yes, you can manage custom PHP snippets via this plugin https://wordpress.org/plugins/code-snippets/
    Thanks @Bemay1 🙂

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

New Reply

This forum has been archived and is no longer accepting new posts or replies. Please join our new community forum for support & discussion.