Make geolocation as optional

  • Author
    Posts
  • vdrive6

    How to make geolocation field as optional instead of required?

    ihordeveloper

    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

    ihordeveloper

    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
    );
Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.

Subscribe

Sign In

Don't have an account? Register

Forgot password?

Register

Already have an account? Sign In

Forgot password?

Reset Password

Please enter your username or email address, you will receive a link to create a new password via email.