Sauter la navigation

[Résolu] Prepopulate CRED form taxonomy field with urlparameter

This support ticket is created Il y a 5 années et 10 mois. 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
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9: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/Karachi (GMT+05:00)

Marqué : 

Ce sujet contient 2 réponses, a 2 voix.

Dernière mise à jour par romanB-3 Il y a 5 années et 10 mois.

Assisté par: Waqar.

Auteur
Publications
#1229793

Hello,

I have this link

<a href="<em><u>lien caché</u></em>">link</a>

where 1863 is the term ID I want to be checked on a page displaying a cred form.

The cred form displays the taxonomy based on

 [cred_field field='nature' force_type='taxonomy' output='bootstrap' display='select' single_select='true' urlparam='nat']

But the select doesn't display the right term, as if it did not recognize the urlparameter.

Thank you.

#1229799

Hi Roman,

Thank you for waiting.

During testing, I was able to confirm that the pre-population of the taxonomy field from a URL parameter is not supported.

For this, you'll need to add some custom script, in the form's "JS editor" tab:
( screenshot: lien caché )


jQuery(document).ready(function() {
  // Construct URL object using current browser URL
  var url = new URL(document.location);

  // Get query parameters object
  var params = url.searchParams;

  // Get value of "nat"
  var nat = params.get("nat");

  // Set it as the dropdown value
  jQuery('select[name="nature[]"]').val(nat);
});

I hope this helps.

regards,
Waqar

#1229805

Thank you, this solved the problem.