n00b alert, how to change listing fields?

This topic contains 3 replies, has 3 voices, and was last updated by  Kiran 5 years, 9 months ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
  • Author
    Posts
  • #520622

    stanm
    Free User
    Post count: 2

    I’m just trying the free version of GD before deciding whether to go with the Pro. Am stuck on something. How do I make the address field a required item?

    I’ve found Places > Settings.

    On the right I’ve got “List of fields that will appear on add new Places form”. With the phone number field I have a box to tick to make it a required field.

    But I need the first line of the address, second line of the address and post code to all be Required fields.

    I can’t find how to do that. Any suggestions?

    TIA

    #520642

    Alex Rollin
    Moderator
    Post count: 27815

    Hello,

    all address fields are required with the exception of the post code. It is not possible to make the other fields optional.

    I will ask the developers if there is a way to make zip code required.

    #520660

    stanm
    Free User
    Post count: 2

    Hi Alex,

    Thanks for your reply.

    The second line of the address and the post code are not showing an asterisk for me – see image attached.

    So it looks, to the general public at least, as though these fields are optional.

    #521090

    Kiran
    Moderator
    Post count: 7069

    Hi stanm,

    Use following PHP snippet to make post code & address 2 fields mandatory.

    
    
    /**
     * Make post code & address 2 mandatory in add listing form.
     */
    function gd_snippet_191212_make_zip_mandatory( $html, $cf ) {
    	if ( ! empty( $html ) ) {
    		// Make Zip/Post Code mandatory.
    		$search1 = '<div id="geodir_address_zip_row"' . PHP_EOL . '                 class="';
    		$replace1 = $search1 . 'required_field ';
    		$search2 = 'initialize_autofill_address();';
    		$replace2 = $search2 . 'var $_zip = jQuery("#geodir_address_zip_row.geodir_form_row");$_zip.append("<span class=\"geodir_message_error\">' . esc_attr__( 'Post Code is required!', 'geodirectory' ) . '</span>");jQuery("label", $_zip).append(" <span>*</span>")';
    
    		// Make Adddress 2 mandatory.
    		$search1 = '<div id="geodir_address_street2_row"' . PHP_EOL . '                 class="';
    		$replace1 = $search1 . 'required_field ';
    		$search2 = 'initialize_autofill_address();';
    		$replace2 = $search2 . 'var $_street2 = jQuery("#geodir_address_street2_row.geodir_form_row");$_street2.append("<span class=\"geodir_message_error\">' . esc_attr__( 'Town / County is required!', 'geodirectory' ) . '</span>");jQuery("label", $_street2).append(" <span>*</span>")';
    
    		$html = str_replace( array( $search1, $search2 ), array( $replace1, $replace2 ), $html );
    	}
    	return $html;
    }
    add_filter( 'geodir_custom_field_input_address', 'gd_snippet_191212_make_zip_mandatory', 100, 2 );

    Regards,
    Kiran

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

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
20% Discount Offer
Hurry! Get your 20% discount before it expires. Get 20% Discount