But i don´t getting this work. Can someone help me with this?
The E-Mail Adress should get checked based on a whitelist Domain list. If the Mailadresse doesn´t containt in the Whitelist domain, the User should get an notice.
Hi Stefan. I recommend enabling Gravity Forms logging and adding some custom logging statements to your code so you can see what is being executed, and what the values are, so you can figure out why it’s not working.
First, enable Gravity Forms logging:
Next, add some custom logging statements to your code:
I like to log inside every loop or conditional and any time you set a variable or retrieve a value. With the additional logging and Gravity Forms logging active, you can check the Gravity Forms Core log and see what is going on. If you need assistance with the log, please share the link to the log file and your updated code so we know what logging statements to look for. Thank you.
The logic you’re checking here wouldn’t really work for what you’re trying to do.
You would first want to start with allowing all the standard validation in the plugin to do its checks prior to running anything custom, then flagging the submission as invalid until your custom check passes.
You’d then want to loop through each allowed domain you’ve declared and then change the validation result back to true if you find a partial match in an email field value.
Something like the following would roughly do the above. Remember that this and your original snippet would only run for form #4 as defined in the filter name on the first line.