Dealing with nonces inside a custom validation function
-
I am trying to sort out the best way to write a custom validation function that doesn’t run afoul of various WordPress coding standards.
I am trying to write a small plugin that extends CF7 with some custom form fields that our organization uses frequently, one of which needs a validation function to be able to set the field to be required.
The simple validation function that I wrote using the documentation is here:
https://github.com/MITLibraries/mitlib-cf7-elements/blob/master/mitlib-cf7-elements.php#L53-L63This function works fine, but it is being flagged by coding standards for not checking a nonce. I found the portion of the documentation to enable nonces for these forms via wp-config.php, and I’ve been able to alter the validation function to check for the nonce existing, but when I try to run wp_verify_nonce() things seem to go sideways.
Am I off base in trying to implement nonces within a custom validation script? When I look at the documentation for wp_verify_nonce(), I see an optional $action parameter, which I can pass in to match one used during nonce creation. Is there such a string used by CF7?
- The topic ‘Dealing with nonces inside a custom validation function’ is closed to new replies.