$slt_userInfos->ID is the value in a hidden field needed for the adminTO processing. The whole thing works without the verification fields, and if I include the form normally – insert_cform() instead of insert_custom_cform(), configured via the admin area – the verification works. But if I include the verification fields in the custom form, it doesn't submit – keeps being returned as if I've not filled in the verification field, or I've got the answer wrong (I definitely haven't).
Am I including the field wrongly in the above code?
PS: if this is only about changing the adminTO on the fly, you can do that easily and more elegantly (and with ajax support) in my-functions.php (logic routine: "adminTO" setting).
Regarding adminTO, I am indeed changing that via my-functions.php. But I'm outputting the form on several user profile pages, and I want the form to submit to the user whose profile it's on. The best way I've found is to have a custom form as above, which carries a hidden field with that user's ID. Then in my-functions.php I get the user's email based on the ID, and change adminTO. If there's way of doing the same thing without a custom form, do let me know.
Otherwise, I'm stuck with the verification issue. I mentioned the adminTO stuff in case there's some obscure relation between that and this issue that I can't see…
for security reasons I would not include a users ID, however you can include the post ID and then use 1 or 2 WP functions in my-functions.php to retrieve the user ID (based on the page/post ID) and user email.
simply enable (will insert two more hidden fields to your form):
I got the solution: simply don't make the verification or captcha field 'required' – I'll make sure to add something to the code to catch this, but these two fields are by nature required and making them "even more required" confused cforms.
But it has the same result: "Please fill in all the required fields", even when the answer's right. I'm not sure if accessing the form itself might help, but I can let you access it by privately emailing a link to you, if you think it'll help.
Regarding user ID, I didn't think it would be a security risk for WP user IDs to be known. How about usernames? I don't think there's anything else I can use other than email (which is obviously not a good idea). The enquiry form comes from a page that will have a salesperson assigned to it (via a Custom Field containing the salesperson's ID or username), but that page itself won't necessarily be created by the salesperson.
But it has the same result: "Please fill in all the required fields", even when the answer's right. I'm not sure if accessing the form itself might help, but I can let you access it by privately emailing a link to you, if you think it'll help.
sure, feel free to send the URL via email.
Regarding user ID, I didn't think it would be a security risk for WP user IDs to be known. How about usernames? I don't think there's anything else I can use other than email (which is obviously not a good idea). The enquiry form comes from a page that will have a salesperson assigned to it (via a Custom Field containing the salesperson's ID or username), but that page itself won't necessarily be created by the salesperson.
if the post's custom field contains the info, even better and easier. simply add some code into your my-functions.php that takes the POST ID (see my above post) and retrieves on the fly your custom fields per that post ID and then derive from that the email address.
that way you don't need any info in the form itself about that user.
Apologies Oliver, on further testing it looks like the issue was with a subject field that I'd pre-filled and disabled. I didn't realize that I should be using read-only, not disabled – it seems that disabling a field, even if it has a value, stops the form from validating.
Not sure if this is correct behaviour, but I've made the pre-filled field read-only rather than disabled, and the form submits OK now.
And thanks for the tip on the hidden user info, I didn't understand your method before!
Apologies Oliver, on further testing it looks like the issue was with a subject field that I'd pre-filled and disabled. I didn't realize that I should be using read-only, not disabled – it seems that disabling a field, even if it has a value, stops the form from validating.
correct, disabled fields are by W3C standards not sent back to the server.
Not sure if this is correct behaviour, but I've made the pre-filled field read-only rather than disabled, and the form submits OK now.
depends on what this field is used for.
And thanks for the tip on the hidden user info, I didn't understand your method before!