Add listing address filter or action

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

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

Open Support Ticket

Tagged: 

  • Author
    Posts
  • #438186

    James Gehring
    Expired Member
    Post count: 34

    I need to modify the add listing form address. Is there a filter or action to accomplish this?

    #438196

    Alex Rollin
    Moderator
    Post count: 27815
    This reply has been marked as private.
    #438209

    Kiran
    Moderator
    Post count: 7069

    Hi James,

    Please provide us some more details how you want it, so i can help you with that if it is achievable via action/filter.

    Kiran

    #438252

    James Gehring
    Expired Member
    Post count: 34

    I am wanting to add a second address field right under the Address field on the add listing form. If it cant be done with via action/filter can you point me to the file that contains the form fields?

    I cant add a custom field for the second address because I need it to be right below the main Address field. I don’t want to modify core plugin files, but will if there is no other way.

    Thanks

    #438256

    Kiran
    Moderator
    Post count: 7069

    Hi,

    Here is example to add custom field under address field:

    
    
    function _gd_custom_extra_address_field( $custom_field ) {
    	?>
    	<div id="geodir_custom_address_row" class="geodir_form_row clearfix gd-fieldset-details">
    		<label><?php _e( 'Custom Address', 'geodirectory' ); ?></label>
    		<input field_type="text" name="geodir_custom_address" id="geodir_custom_address" class="geodir_textfield gd-form-control" type="text">
    		<span class="geodir_message_note"></span>
    	</div>
    	<?php
    }
    add_action( 'geodir_address_extra_listing_fields', '_gd_custom_extra_address_field', -10, 1 );

    Thanks,
    Kiran

    #438269

    James Gehring
    Expired Member
    Post count: 34

    That works. Will it create a column in the database or do I need to create one for it?

    #438358

    Kiran
    Moderator
    Post count: 7069

    Hello,

    You have to create field from GeoDirectory > CPT Settings (eg: Place Settings).
    Create field with html var name (key) = custom_address. Reason behind adding field via field manager is you do not need to write any extra code to save field on submit listing.

    There is a chance that field may display twice on form. One via manually by my snippet and one via custom field manager. You can hide field that will be displayed via field manager by using hook: https://github.com/GeoDirectory/geodirectory/blob/master/geodirectory-functions/custom_fields_input_functions.php#L78

    Kiran

    #438688

    James Gehring
    Expired Member
    Post count: 34

    If I fill in the field your code creates it doesn’t save to the database. If I save to the field that is created when adding to the GeoDirectory > CPT Settings it will. Any idea whats going on?

    #438696

    Alex Rollin
    Moderator
    Post count: 27815

    Hello,

    You have to create field from GeoDirectory > CPT Settings (eg: Place Settings).
    Create field with html var name (key) = custom_address.

    As Kiran said above, you do not JUST use the code, you also have to create the field, and then edit the code (if necessary) with the html var name to make them match.

    this is a customization and you should contact a GD Expert if you need hands on help with it.

    http://geodirectoryexperts.com

    #438698

    James Gehring
    Expired Member
    Post count: 34

    I created the field as he said and used the exact input. I don’t need an expert to help me as my skills are pretty high level, I just thought Y’all might know what was happening since I set it up the way it was told to me.

    Thanks for your help. I will figure out why it is not saving on my own since it seems that reading isn’t yalls specialty.

    Like I had said in my previous reply.

    If I fill in the field your code creates it doesn’t save to the database.

    That is the field your action created. It did not save

    If I save to the field that is created when adding to the GeoDirectory > CPT Settings it will.

    This is the code that was generated when I created the custom field in the back end.

    <input field_type="text" name="geodir_custom_address" id="geodir_custom_address" class="geodir_textfield gd-form-control" type="text">

    The input your code created

    <input field_type="text" name="geodir_custom_address" id="geodir_custom_address" type="text" class="geodir_textfield">

    The input auto-created from the custom field. As you can see they are almost identical.

    But thanks for your help anyways

    #438753

    Kiran
    Moderator
    Post count: 7069
    This reply has been marked as private.
Viewing 11 posts - 1 through 11 (of 11 total)

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

Open Support Ticket