Skip Navigation

[Resolved] Select categories and taxonomy based on url parameters

This support ticket is created 3 years, 11 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 2 replies, has 2 voices.

Last updated by Luit 3 years, 11 months ago.

Assisted by: Minesh.

Author
Posts
#1884943

My goal is: Select categories and taxonomy based on url parameters in a form

https://toolset.com/forums/topic/get-url-parameter-for-cred-form-taxonomy-and-select-it/

If found this thread and managed to use the first jscript to select a category in my add a new post form. So this works.

But I have a conditional in a select field (Kerntaken= taxonomy) based on the selected category to display a specific taxonomy

So the category "Opdrachten" is selected based on url parameter /?categorie=Opdrachten. But based on this selection a second url parameter ?kerntaak= should make a selection for the taxonomy selection field, for example ?kerntaak=training which should select the taxonomy "Geven van trainingen".

The jscript I use for the caregory:

var getUrlParameter = function getUrlParameter(sParam) {
var sPageURL = decodeURIComponent(window.location.search.substring(1)),
sURLVariables = sPageURL.split('&'),
sParameterName,
i;

for (i = 0; i < sURLVariables.length; i++) {
sParameterName = sURLVariables[i].split('=');

if (sParameterName[0] === sParam) {
return sParameterName[1] === undefined ? true : sParameterName[1];
}
}
};
var param = getUrlParameter('categorie');

jQuery('select[name="category[]"]').find("option:contains('" + param + "')").attr('selected', 'selected');

I copied this script and adjusted the variables (this works) but then I get errors when saving the form: wrong combination of variables use.

#1885099

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Can you please share problem URL where I can see the form you added as well as access details and tell me at what step its not working. Maybe a video that explains the issue would be enough.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#1887257

Thanks, I found another solution by using conditional groups in the form. I use an URL parameter to select the correct category, the form then selects the correct taxonomy based on the category.

My issue is resolved now. Thank you!