Support » Plugin: Events Manager » Pre-Purchase Question: Search By Zip Code Widget

Viewing 13 replies - 1 through 13 (of 13 total)
  • sorry, but that isn’t available at the moment; but if you can code in php this is possible.

    Plugin Author Marcus

    (@netweblogic)

    NetWebLogic Support

    somebody submitted this to me a while ago, still untested, but may help:

    <?php
    // this filter adds the logic to the SQL query to take the postcode and compare it to the lat / lng of the location.
    add_filter( 'em_events_build_sql_conditions', 'my_em_scope_conditions',1,2);
    function my_em_scope_conditions($conditions, $args){
    	if( !empty($args['postcode']) ){
    
    	$base_url = "http://maps.google.com/maps/geo?output=xml&key=[your google key here]";
    
        $request_url = $base_url . "&q=" . urlencode($args['postcode']);
        $xml = simplexml_load_file($request_url);
    
        $status = $xml->Response->Status->code;
        if (strcmp($status, "200") == 0) {
          // Successful geocode
          $geocode_pending = false;
          $coordinates = $xml->Response->Placemark->Point->coordinates;
          $coordinatesSplit = split(",", $coordinates);
          // Format: Longitude, Latitude, Altitude
          $lat = $coordinatesSplit[1];
          $lng = $coordinatesSplit[0];
          $radius=$input_radius;
    	}
    	$conditions['scope'] = " (3956 * 2 * ASIN(SQRT(POWER(SIN(('".$lat."' - abs(location_latitude))*pi()/180/2),2) + COS('".$lat."' * pi()/180) * COS(abs(location_latitude) * pi()/180) * POWER(SIN(('".$lng."' - location_longitude) * pi()/180/2),2))) < '".$radius."')";	
    
    	}
    	return $conditions;
    }
    ?>

    How To Safely Add PHP Code To WordPress

    Marcus, thanks for this. I’m not a coder but I will give it a try.

    Any chance of implementing something like this in the near future?

    Thanks.

    BTW, where should I put this code?

    It needs to go in the functions.php file of your theme.

    I added the code but don’t see anything different. What should I be looking for? I don’t see a widget and/or zip code search field on Events page.

    Plugin Author Marcus

    (@netweblogic)

    NetWebLogic Support

    good point, that part hasn’t been added. you would need to add that yourself, but you’re looking to add the postcode field to your search e.g. [events_list postcode=”x”]

    check this tutorial out, maybe that’ll help – http://wp-events-plugin.com/tutorials/adding-custom-event-search-form-fields/

    @marcus, as you know, I just purchased the PRO upgrade and look forward to using it.

    I am commissioning a developer to create the zip code search widget and shortcode for your plugin right now and it should be done hopefully soon so I look forward to integrating that into my own site as well.

    Thank you.

    Plugin Author Marcus

    (@netweblogic)

    NetWebLogic Support

    thanks!

    you may want to look at this, because it turns out the code above is using outdated google APIs, we’re working on some alternatives:

    http://wordpress.org/support/topic/plugin-events-manager-add-simple-placeholder-for-zip-code-distance?replies=13

    Hi Marcus, I’m looking at buying the pro version as need the ticket purchasing option, but would also be very interested in searching for events near a zip/postcode – ideally with a 10, 20, 50, 100 mile radius.

    Have you got any closer with the alternatives? Is it something you are looking to include in a future update?

    Many thanks.

    hi,

    we are already working on this and will update you once done.

    Fantastic, any idea of a time line?

    Regards,
    David

    Plugin Author Marcus

    (@netweblogic)

    NetWebLogic Support

    no exact eta’s, sorry

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Pre-Purchase Question: Search By Zip Code Widget’ is closed to new replies.