Hi folks! The contact form on a client site has multiple subjects in a drop down list and I want to preselect one subject depending on where the user is comming from.
Reading the “How To: Passing query string parameters to contact form page” this should be possible by simply passing [form number]subject_id=[number] as param. So my Link is something like blogurl.tld/contact/?1subject_id=1 (or 2,3,…).
Unfortunately this doesn’t work…the first option is always selected no matter what I pass as ID in the query string!
So I went into the code and I think I found the reason: The select is build in si-contact-form-display.php on line 373-411. On line 394 there is an if-clause which checks if the subject ID (sid) is set. If it’s not set and if we set the subject id in the query param the sid is extracted from the url. The thing is: sid is always set, because it is assigned ‘1’ as default on line 1016 in si-contact-form.php. That’s why the first option is always selected and the query string param doesn’t work for subject drop down list…
You could unset the sid before the if-clause on line 394. That would make it work. Can someone confirm this? Is unsetting a solid solution?
- The topic ‘Preselect subject in drop down: subject ID as query string param doesn't work’ is closed to new replies.