Title: location
Last modified: March 31, 2022

---

# location

 *  Resolved [anwind](https://wordpress.org/support/users/anwind/)
 * (@anwind)
 * [4 years, 5 months ago](https://wordpress.org/support/topic/location-25/)
 * Hello
    There is a service, [https://dadata.ru](https://dadata.ru) / with which
   you can implement hints for the location field. Here is an attempt at integration:
   <script> $(“#adverts_location”).suggestions({ token: “11111111111111111111111111111”,
   type: “ADDRESS”, /* Called when the user selects one of the suggestions */ onSelect:
   function(suggestion) { console.log(suggestion); } }); </script> But from the 
   add form does not work. Presumably because of the styles. Can you help in the
   implementation of the plan?

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

 *  Plugin Author [Greg Winiarski](https://wordpress.org/support/users/gwin/)
 * (@gwin)
 * [4 years, 5 months ago](https://wordpress.org/support/topic/location-25/#post-15516604)
 * Hi,
    can you send a link to the page where you have this code or your whole code
   snippet?
 * The way you have it now I think that either:
    – there will be error saying the
   $ is null since the code does not wait for the jQuery library to be loaded – 
   there will be error saying the .suggestions() is undefined as it does not look
   like you are loading it anywhere.
 *  Thread Starter [anwind](https://wordpress.org/support/users/anwind/)
 * (@anwind)
 * [4 years, 5 months ago](https://wordpress.org/support/topic/location-25/#post-15516648)
 * [https://websgood.ru/primer](https://websgood.ru/primer)
 * it would be great to implement this in the location field on the add page and
   in the search form.
 *  Plugin Author [Greg Winiarski](https://wordpress.org/support/users/gwin/)
 * (@gwin)
 * [4 years, 5 months ago](https://wordpress.org/support/topic/location-25/#post-15523390)
 * Hi,
    thanks, but this field does not seem to be connected to the [adverts_add]
   form in any way?
 * Does the [https://dadata.ru](https://dadata.ru) have some documentation in English
   so i could take a look at it?
 *  Thread Starter [anwind](https://wordpress.org/support/users/anwind/)
 * (@anwind)
 * [4 years, 5 months ago](https://wordpress.org/support/topic/location-25/#post-15523443)
 * Unfortunately not in English. The example is not related to [adverts_add] it’s
   just the logic of what would be nice to do. It is a pity that it is impossible
   to implement the plan.
 *  Plugin Author [Greg Winiarski](https://wordpress.org/support/users/gwin/)
 * (@gwin)
 * [4 years, 5 months ago](https://wordpress.org/support/topic/location-25/#post-15523539)
 * If you could point me to some Russian docs with code snippets/examples showing
   how to use the API I might be able to work with it as well.
 * I think the suggestions should be possible and it shouldn’t really be hard to
   use them but I first need to understand how it is being run.
 *  Thread Starter [anwind](https://wordpress.org/support/users/anwind/)
 * (@anwind)
 * [4 years, 5 months ago](https://wordpress.org/support/topic/location-25/#post-15523595)
 * [https://dadata.ru/suggestions/usage/address/](https://dadata.ru/suggestions/usage/address/)
 * To connect to the domain, registration on the website is required [https://dadata.ru](https://dadata.ru)
 *  Plugin Author [Greg Winiarski](https://wordpress.org/support/users/gwin/)
 * (@gwin)
 * [4 years, 5 months ago](https://wordpress.org/support/topic/location-25/#post-15527565)
 * The minimal code required to get the Dadata.ru working with adverts_location 
   field would be something like this
 *     ```
       add_action( "init", function() {
           wp_register_style( 'dataru-css', 'https://cdn.jsdelivr.net/npm/suggestions-jquery@21.12.0/dist/css/suggestions.min.css', array(), "21.12.0" );
           wp_register_script( 'dataru-js', 'https://cdn.jsdelivr.net/npm/suggestions-jquery@21.12.0/dist/js/jquery.suggestions.min.js', array( 'jquery' ), "21.12.0" );
       });
       add_action( 'wp_enqueue_scripts', function() {
           wp_enqueue_script( 'dataru-js' );
           wp_enqueue_style( 'dataru-css' );
       });
       add_action( 'wp_footer', function() {
           ?>
           <script type="text/javascript">
           document.addEventListener("DOMContentLoaded", function(event) { 
               if( jQuery("#adverts_location").length === 0) {
                   return;
               }
               jQuery("#adverts_location").suggestions({
                   token: "${API_KEY}",
                   type: "ADDRESS",
                   /* Вызывается, когда пользователь выбирает одну из подсказок */
                   onSelect: function(suggestion) {
                       console.log(suggestion);
                   }
               });
           });
           </script>
           <?php
       },1000);
       ```
   
 * You just need to update the API key and probably change the line `console.log(
   suggestion);` to something that will fill the location field value with the selected
   suggestion.
 *  Thread Starter [anwind](https://wordpress.org/support/users/anwind/)
 * (@anwind)
 * [4 years, 5 months ago](https://wordpress.org/support/topic/location-25/#post-15527734)
 * Good afternoon. Did I understand correctly.
    1. The code I added to the plugin
   is profunctions 2. Added my API
 *     ```
       add_action( "init", function() {
           wp_register_style( 'dataru-css', 'https://cdn.jsdelivr.net/npm/suggestions-jquery@21.12.0/dist/css/suggestions.min.css', array(), "21.12.0" );
           wp_register_script( 'dataru-js', 'https://cdn.jsdelivr.net/npm/suggestions-jquery@21.12.0/dist/js/jquery.suggestions.min.js', array( 'jquery' ), "21.12.0" );
       });
       add_action( 'wp_enqueue_scripts', function() {
           wp_enqueue_script( 'dataru-js' );
           wp_enqueue_style( 'dataru-css' );
       });
       add_action( 'wp_footer', function() {
          ?>
           <script>
           document.addEventListener("DOMContentLoaded", function(event) { 
               if( jQuery("#adverts_location").length === 0) {
                   return;
               }
               jQuery("#adverts_location").suggestions({
                   token: "71198f64877251cba46a2a88ab061f4a4369298a",
                   type: "ADDRESS",
                   /* Вызывается, когда пользователь выбирает одну из подсказок */
                   onSelect: function(suggestion) {
                       console.log(suggestion);
                   }
               });
           });
           </script>
           <?php
       },1000);
       ```
   
 * Does not work [https://websgood.ru/adverts/add?preselected_category=dlya-avtomobilej](https://websgood.ru/adverts/add?preselected_category=dlya-avtomobilej)
    -  This reply was modified 4 years, 5 months ago by [anwind](https://wordpress.org/support/users/anwind/).
    -  This reply was modified 4 years, 5 months ago by [anwind](https://wordpress.org/support/users/anwind/).
 *  Plugin Author [Greg Winiarski](https://wordpress.org/support/users/gwin/)
 * (@gwin)
 * [4 years, 5 months ago](https://wordpress.org/support/topic/location-25/#post-15531215)
 * It seems to be working fine but the suggestions are conflicting with the theme
   CSS and are not visible try adding the below code in the wp-admin / Appearance/
   Customize / Additional CSS panel
 *     ```
       .suggestions-wrapper {
         overflow: hidden !important;
         height: auto !important;
         min-height: 100px;
         position: initial !important;
       }
       ```
   
 * Also the code snippet from the previous message is showing in your source code
   twice for some reason, you should show it once only.
 *  Thread Starter [anwind](https://wordpress.org/support/users/anwind/)
 * (@anwind)
 * [4 years, 5 months ago](https://wordpress.org/support/topic/location-25/#post-15531289)
 * Oh, yes, adding styles helped, it works. Thanks.
 *  Plugin Author [Greg Winiarski](https://wordpress.org/support/users/gwin/)
 * (@gwin)
 * [4 years, 5 months ago](https://wordpress.org/support/topic/location-25/#post-15535097)
 * Ok great, I am glad you have it the way you wanted it, I am marking the thread
   as resolved, maybe someone in the future will find it helpful.
 * BTW. If you are finding the plugin useful i would be thankful if you could write
   a short one or two sentence review here [https://wordpress.org/support/view/plugin-reviews/wpadverts](https://wordpress.org/support/view/plugin-reviews/wpadverts)

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

 The topic ‘location’ is closed to new replies.

 * ![](https://ps.w.org/wpadverts/assets/icon-256x256.png?rev=2423472)
 * [WPAdverts - Classifieds Plugin](https://wordpress.org/plugins/wpadverts/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wpadverts/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wpadverts/)
 * [Active Topics](https://wordpress.org/support/plugin/wpadverts/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wpadverts/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wpadverts/reviews/)

 * 11 replies
 * 2 participants
 * Last reply from: [Greg Winiarski](https://wordpress.org/support/users/gwin/)
 * Last activity: [4 years, 5 months ago](https://wordpress.org/support/topic/location-25/#post-15535097)
 * Status: resolved