Marker filter by custom field

New home Forums Visitor Generated Markers General queries Marker filter by custom field

This topic contains 10 replies, has 5 voices, and was last updated by  maph01 1 year, 2 months ago.

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #41779

    ikoymaster
    Member

    Hi, is it possible to filter the displayed marker by custom field?

    I don’t just mean the markers on the marker list, but also the markers on the map itself.

    If this is not possible in your current version, can you point me in the right direction on how to achieve this.

    Please reply as soon as you can.

    Cheers!

    #41895

    Steven
    Moderator

    Hi there,

    We really appreciate you getting in touch.

    Unfortunately this is not supported at this point in time.

    In order to achieve this various core changes would be required and as such I would like to ask you to get in touch here: https://www.wpgmaps.com/customization-requests/

    I hope this helps.

    Kindest Regards,
    Steve

    #41926

    jasonh
    Member

    I thought this was possible. When I edit the map and then the “Marker Filtering” tab, it lets me choose the custom fields I want to filter on. Then when I view the map, I see the drop downs for my custom fields.

    Although, I can’t get custom fields to save, so the dropdowns are empty. So how do we get custom fields to save? I’m running 7.10.21 of the PRO version.

    So the filtering is not working, but it looks like it will work if I can get the actual custom fields to save.

    Thoughts?

    #41927

    ikoymaster
    Member

    @jasojh

    “So how do we get custom fields to save?”
    I have a custom code that inserts into custom fields table. The custom fields from the admin page doesn’t seem to work.

    #41934

    jasonh
    Member

    Would it be possible to share your code? Also – are you able to “filter” by these custom fields?

    #41935

    ikoymaster
    Member

    Of course, however let me explain what I did.

    I wanted to tag the markers based on who created them and to what post they are linked to. I am not using the admin UI when creating markers(custom fields don’t save). So I created a front-end form that creates a post, and then create a marker for that post and link them together. All these happen in the front-end.

    Here:
    CODE SNIPPET TO CREATE MARKER: wp_user and post_id are the custom fields.

    $ins_array = array(
    							'map_id' => 1,
    							'title' => $title,
    							'address' => $_POST["wpgmza_ugm_add_address"],//$_POST["wpgmza_ugm_add_address"] ,
    							'description' => $description,
    							'pic' => $img_src,
    							//'icon' => $icon,
    							'link' => get_permalink($post_id),
    							'lat' => $_POST["wpgmza_ugm_lat"],
    							'lng' => $_POST["wpgmza_ugm_lng"],
    							'anim' => 0,
    							'category' => 0,
    							'infoopen' => 0,
    							'retina' => 0
    						);
    
    						$wpdb->insert( "wpx2_wpgmza", $ins_array );
    						$marker_id = $wpdb->insert_id;
    						my_marker_customfields($marker_id, "wp_user", $_POST['wp_user']);
    						my_marker_customfields($marker_id, "post_id", $post_id);

    FUNCTION TO INSERT/UPDATE CUSTOM FIELDS

    function my_marker_customfields($marker_id, $field_id, $value, $update = false){
    	global $wpdb;
    	$data = array(
    			'field_id' => $field_id,
    			'object_id' => $marker_id,
    			'value' => $value
    			);
    	if(!$update){
    		$wpdb->insert( "{$wpdb->prefix}wpgmza_markers_has_custom_fields", $data );
    	}else{
    		$wpdb->update( 
    						"{$wpdb->prefix}wpgmza_markers_has_custom_fields", 
    						$data, 
    						array( 'field_id' => $field_id,
    						 		'object_id' => $marker_id,)
    					);
    	}
    }

    I haven’t had the chance to finish working on filtering the markers for now. I will try to update here when I do to give back to the community. 🙂

    Hope this helps. Happy hacking!!!

    #41953

    Steven
    Moderator

    Hi all,

    Thank you so much for your time.

    With regards to the custom fields not saving, we believe this may be due to a failure within our activation hook.

    More specifically I believe the custom fields table may not be created and as such I would like to ask that you attempt to deactivate both basic and the Pro plugin and then continue to reactivate both plugins in order.

    Reactivating the plugin should allow the hooks to fire and create any missing tables or columns within the database.

    Once complete please let me know if this resolves the issue, if not I will report this to the developer.

    Kindest Regards,
    Steve

    #41965

    jasonh
    Member

    That didn’t work. Just to be clear what the issue is – I can create “Custom Fields”. And when I go to edit or create a marker, I see the fields for those custom fields. But when I save the marker, they aren’t saved for that marker.

    Furthermore – when I click to edit the next marker, the same values that I tried to enter in the custom fields for the previous marker still show up, they never get cleared out.

    #41973

    Steven
    Moderator

    Hi there,

    We really appreciate your time and patience.

    I do believe our lead developer is contact with you via our support desk and he will assist you further.

    We do really appreciate your time on this.

    Kindest Regards,
    Steve

    #42521

    privla
    Member

    Hello, I have the same problem.

    When I bought your pro plugin I read “Add custom fields to your markers and allow users to filter by them!” but that doesn’t work.

    I will explain in more detail what is happening to me:
    I added Custom Field with name “Price” with filter type Dropdown.

    And then when I went on Markers > Add a marker and I put in field “Price” (which is a custom field) values for that the marker ($ or $$ or $$$ or $$$$)

    Problem: on the website you see up-left field Price and when you click on it you can choose in dropdown values $, $$, $$$, $$$$ but these values are not filtered as they should.
    Eg. If you choose value $ and after that value $$ you can see that many markers didn’t disappear (which are value $) and replaced with those who have value $$.

    Please help!

    #42818

    maph01
    Member

    [quote quote=41965]That didn’t work. Just to be clear what the issue is – I can create “Custom Fields”. And when I go to edit or create a marker, I see the fields for those custom fields. But when I save the marker, they aren’t saved for that marker.

    Furthermore – when I click to edit the next marker, the same values that I tried to enter in the custom fields for the previous marker still show up, they never get cleared out.[/quote]

    I have the same issue, I tried deactivating and activating the plugins, and no luck. I manually inserted the values in the table, and they are pulled in the front end, but not in the Marker edit page =S

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

You must be logged in to reply to this topic.