Force VGM to a certain category

New home Forums Visitor Generated Markers General queries Force VGM to a certain category

  • This topic has 10 replies, 2 voices, and was last updated 1 year ago by Matthew.
Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #74684
    guycaris
    Participant

    Hi,
    Is it possible to add a VGM into the category specifed in the shortcode. So I could set the ‘ Allow users to select a marker category?’ to No, but the VGM would add into the category set in the shortcode.
    Thanks

    #74692
    Matthew
    Moderator

    Hi there,

    Thank you for getting in touch with us, we do appreciate your time.

    Unfortunately we do not have category parameter for the VGM shortcode to do this, however, you may achieve a similar functionality using some custom JS code which I am happy to assist you with.

    The code would essentially work with the “Allow users to select a marker category” setting enabled, as the code will start by identifying the page, setting the preferred category in the category dropdown and then hiding the category dropdown input. This would allow for the marker to be set to the preferred category without the user being able to change the category.

    Please do let me know if this would help?

    I look forward to hearing back from you.

    Kindest Regards,
    Matthew

    #74699
    guycaris
    Participant

    Hi there, yes that would work, that would be great if you could help me with it
    Thanks

    #74701
    Matthew
    Moderator

    Hi there,

    Thank you for getting back to me and for your time.

    Yes sure, thus please may I ask if you may provide me with the link to your page on your site that contains your VGM form, as well as confirm which category are the markers supposed to be assigned to?

    Please may you also ensure that the “Allow users to select a marker category category” setting for your map is enabled.

    I look forward to hearing back from you.

    Kindest Regards,
    Matthew

    #74704
    guycaris
    Participant
    This reply has been marked as private.
    #74710
    Matthew
    Moderator

    Hi there,

    Thank you for your continued time on this, I really appreciate it!

    Thank you for the confirmation, however, please may you provide me with the link to your site as well as your respective map pages so that I may take a closer look?

    I look forward to your response.

    Kindest Regards,
    Matthew

    #74713
    guycaris
    Participant

    sorry, forgot to add a link
    http://www.rallyespot.com

    #74724
    Matthew
    Moderator

    Hi there,

    Thank you for the link, thus please see the below code that I have written for you below:

    jQuery(function($){
        $(document).ready(function(){
            let vgmForm = $('.wpgmaps_user_form');
    
            if(typeof vgmForm != 'undefined' && vgmForm.length > 0){
                let mapCat = WPGMZA.maps[0].shortcodeAttributes.cat;
    
                if(typeof mapCat != 'undefined'){
                    let categoryInput = $(vgmForm.find('#wpgmza_category'));
                    categoryInput.val(parseInt(mapCat));
                    categoryInput.trigger('change');
                }
            }
        })
    })

    Please may you copy, paste and save the above code into the “Custom JS” setting block (Maps -> Settings -> Advanced Settings)?

    Once this has been done, please may you clear your browser cache and confirm if this helps?

    Note that the above code looks for the ‘cat’ parameter in your map shortcode and thus will set the VGM form’s category dropdown to the category ID set.

    I look forward to hearing back from you.

    Kindest Regards,
    Matthew

    #74729
    guycaris
    Participant

    That’s great, thanks very much.
    Is there anyway the dropdwon could be disabled to the user so they cant change it?
    Thanks

    #74730
    guycaris
    Participant

    Hi, ignore last request,
    I have just hidden it and that works fine.
    Thanks much for your help, works perfectly!
    regards
    Guy

    #74733
    Matthew
    Moderator

    Hi Guy,

    Thank you for getting back to me and most valued time, I tremendously appreciate it!

    I am most happy to hear that, and it was my great pleasure assisting you with this.

    Please may you kindly consider reviewing our plugin at https://wordpress.org/support/plugin/wp-google-maps/reviews/#new-post?

    It would really mean the world to me! And if possible, please could I kindly ask you to mention both your name and mine in the review for administrative purposes as this would be a tremendous help?

    Should you ever require any further assistance, I am more than happy to help.

    Have a fantastic day further!

    Kindest Regards,
    Matthew

Viewing 11 posts - 1 through 11 (of 11 total)
  • You must be logged in to reply to this topic.