Add listing address filter or action
This topic contains 10 replies, has 3 voices, and was last updated by Kiran 6 years, 5 months ago.
We have moved to a support ticketing system and our forums are now closed.
Open Support TicketTagged: snippet
-
AuthorPosts
-
July 12, 2018 at 6:32 pm #438186
I need to modify the add listing form address. Is there a filter or action to accomplish this?
July 12, 2018 at 9:36 pm #438196This reply has been marked as private.July 13, 2018 at 4:05 am #438209Hi 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
July 13, 2018 at 12:23 pm #438252I 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
July 13, 2018 at 12:35 pm #438256Hi,
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,
KiranJuly 13, 2018 at 2:54 pm #438269That works. Will it create a column in the database or do I need to create one for it?
July 14, 2018 at 5:14 am #438358Hello,
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
July 16, 2018 at 5:42 pm #438688If 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?
July 16, 2018 at 6:33 pm #438696Hello,
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.
July 16, 2018 at 6:43 pm #438698I 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
July 17, 2018 at 5:58 am #438753This reply has been marked as private. -
AuthorPosts
We have moved to a support ticketing system and our forums are now closed.
Open Support Ticket