• Carin

    (@sparksfreebies)


    Hi, I have chosen specific small towns in our County for Locations and put maps for them, but users cannot select more than one, is there a workaround to allow for multiple selections of pre-set Locations?

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Greg Winiarski

    (@gwin)

    Hi,
    if you would like users to select more than one location when posting/editing an Ad then this is not possible.

    Thread Starter Carin

    (@sparksfreebies)

    Hi Greg, thats bad news for me, do you think my developer could write a plugin to modify that, or what would you suggest as a workaround

    Plugin Author Greg Winiarski

    (@gwin)

    Hi,
    if you are using MAL and would like each selected location to be visible on map, then this will require rewriting the whole MAL extension.

    The best you could do is allow users to select multiple locations from the taxonomy dropdown or autocomplete, then you might be able to have multiple locations selected although c cannot tell if this will save properly in the database, i am sure though that the longitude and latitude will not save.

    Thread Starter Carin

    (@sparksfreebies)

    I really do not even need to display the map as much as the Pre-set Location names, so there would be a way to have users be able to select multiple locations from the taxonomy dropdown, and that would be displayed in the Ad? (map not required). That would be fine, and greatly appreciated an idea of how to proceed. Shall I submit a Pro Member request?

    Plugin Author Greg Winiarski

    (@gwin)

    You can allow multiple selections in the Autocomplete by adding the code below in your theme functions.php file

    
    add_flter( "wpadverts_mal_field_location_data_save", function( $args ) {
      $args["multi"] = "true";
    } );
    

    That being said I looked into the source code and while this should allow multi selection it will most likely not save multiple results.

    One alternative approach you can use is remove the location field from the [adverts_add] form, then add a new Autocomplete field and link it to the Adverts Location taxonomy.

    Thread Starter Carin

    (@sparksfreebies)

    Hi Greg, You saved the day again! Thank you , the second option sounds perfect, should I just disable the MAL plugin if I am creating my own Location Field?

    Plugin Author Greg Winiarski

    (@gwin)

    Hi,
    it would be better to leave it enabled, if you prefer to disable it as you might be using the taxonomy only, then make sure you register the advert_location taxonomy in your theme functions.php file or in the plugin with code snippets

    
    add_action( "init", function() {
        $labels = array(
            'name'              => _x( 'Locations', 'taxonomy general name', 'wpadverts-mal' ),
            'singular_name'     => _x( 'Location', 'taxonomy singular name', 'wpadverts-mal' ),
            'search_items'      => __( 'Search Locations', 'wpadverts-mal' ),
            'all_items'         => __( 'All Locations', 'wpadverts-mal' ),
            'parent_item'       => __( 'Parent Location', 'wpadverts-mal' ),
            'parent_item_colon' => __( 'Parent Location:', 'wpadverts-mal' ),
            'edit_item'         => __( 'Edit Location', 'wpadverts-mal' ),
            'update_item'       => __( 'Update Location', 'wpadverts-mal' ),
            'add_new_item'      => __( 'Add New Location', 'wpadverts-mal' ),
            'new_item_name'     => __( 'New Location Name', 'wpadverts-mal' ),
            'menu_name'         => __( 'Locations', 'wpadverts-mal' ),
        );
        
        $args = array(
            'hierarchical' => true,
            'labels' => $labels,
            'query_var' => true,
            'show_ui' => true,
            'rewrite' => array('slug' => 'advert-location')
        );
        
        register_taxonomy( 
            'advert_location', 
            apply_filters( 'wpadverts_mal_register_taxonomy_post_type', array( 'advert' ), 'advert_location' ), 
            apply_filters( 'wpadverts_mal_register_taxonomy', $args, 'advert_location') 
        );

    } );
    `

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Choose multiple Locations MAL plugin’ is closed to new replies.