WordPress.org

Ready to get started?Download WordPress

Forums

Events Manager
[resolved] Pre-Purchase Question: Search By Zip Code Widget (14 posts)

  1. ehong33234
    Member
    Posted 1 year ago #

    Hi, I plan on buying the pro account but would like to know if you have a widget that allows for a front end user to search for an event by zip code. Perhaps they could do it on the landing page of Events but it would be nice to have a quick widget for zip code and distance search.

    Thanks!

    http://wordpress.org/extend/plugins/events-manager/

  2. agelonwl
    Member
    Posted 1 year ago #

    sorry, but that isn't available at the moment; but if you can code in php this is possible.

  3. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 1 year ago #

    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;
    }
    ?>

    http://wp-events-plugin.com/tutorials/how-to-safely-add-php-code-to-wordpress/

  4. ehong33234
    Member
    Posted 1 year ago #

    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.

  5. ehong33234
    Member
    Posted 1 year ago #

    BTW, where should I put this code?

  6. caimin_nwl
    NetWebLogic Support
    Posted 1 year ago #

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

  7. ehong33234
    Member
    Posted 1 year ago #

    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.

  8. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 1 year ago #

    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/

  9. ehong33234
    Member
    Posted 1 year ago #

    @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.

  10. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 1 year ago #

    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

  11. davinian
    Member
    Posted 1 year ago #

    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.

  12. angelo
    NetWebLogic Support
    Posted 1 year ago #

    hi,

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

  13. davinian
    Member
    Posted 1 year ago #

    Fantastic, any idea of a time line?

    Regards,
    David

  14. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 1 year ago #

    no exact eta's, sorry

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.