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.
-
AuthorPosts
-
September 14, 2022 at 7:29 pm #74684guycarisParticipant
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.
ThanksSeptember 15, 2022 at 9:45 am #74692MatthewModeratorHi 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,
MatthewSeptember 15, 2022 at 12:09 pm #74699guycarisParticipantHi there, yes that would work, that would be great if you could help me with it
ThanksSeptember 15, 2022 at 4:03 pm #74701MatthewModeratorHi 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,
MatthewSeptember 15, 2022 at 5:42 pm #74704guycarisParticipantThis reply has been marked as private.September 16, 2022 at 7:44 am #74710MatthewModeratorHi 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,
MatthewSeptember 16, 2022 at 10:20 am #74713guycarisParticipantsorry, forgot to add a link
http://www.rallyespot.comSeptember 19, 2022 at 10:37 am #74724MatthewModeratorHi 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,
MatthewSeptember 21, 2022 at 12:28 am #74729guycarisParticipantThat’s great, thanks very much.
Is there anyway the dropdwon could be disabled to the user so they cant change it?
ThanksSeptember 21, 2022 at 12:40 am #74730guycarisParticipantHi, ignore last request,
I have just hidden it and that works fine.
Thanks much for your help, works perfectly!
regards
GuySeptember 21, 2022 at 8:10 am #74733MatthewModeratorHi 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 -
AuthorPosts
- You must be logged in to reply to this topic.