How to add fields in custom registration form, validate it and aave to db? [closed]

To modify the theme’s registration would be possible, but definitely not recommended. It is likely that you would only be able to add your additional fields by directly modifying the theme files, especially with something like user registration. It would be a pain to maintain if you intend to keep your theme up to date. … Read more

Ajax Validation for reCaptcha

Just found out that reCaptcha actually rejects CAPTCHAs which are submitted to their server more than once. Since I was using the WP-reCAPTCHA plugin, the plugin resubmitted the CAPTCHA after my AJAX submission. So I just commented out a line from the plugin that does the submission, which is in file recaptcha.php, line 27: $this->register_filters();

Output Sanitation

Your code is working correctly. If you look at the source code of the page, you will see: &lt;script&gt;alert(&#039;Test&#039;)&lt;/script&gt; When the above text gets processed for display by your browser, it then becomes <script>alert(‘Test’)</script> which is what you want to be displayed.

Warn user that data may be lost for custom pages

you have to make a javascript code similar to this… jQuery(function ($) { name = $(‘#name’).val(); $(‘#name’).data(‘old_value’,name); window.onbeforeunload = function () { if ($(‘#name’).data(‘old_value’) !== $(‘#name’).val()) return ‘You have unsaved changes!’; } }); here’s a demo page… try closing the page after changing the value of the textbox there…

Require user to input code from an array of allowed codes with Gravity Forms [closed]

Try below code: add_filter( ‘gform_field_validation’, ‘custom_validation’, 10, 4 ); function custom_validation( $result, $value, $form, $field ) { $arrWhitelist = array(‘XH6D’, ‘8U2A’, ‘L9D3’); if ( $result[‘is_valid’] && !in_array( $value, $arrWhitelist )) { $result[‘is_valid’] = false; $result[‘message’] = ‘Please enter a value less than 10’; } return $result; } Further, You can review validation in more detail … Read more

How to escape multiple attribute at once in WordPress?

The reason you escape attributes is to make sure that the values don’t have any characters that will break the HTML of the element. For example, if you didn’t escape: $attr=”foo”> <script>alert(“Bad!”);</script>”; Then this: <div class=”<?php echo $attr; ?>”></div> Would output: <div class=”foo”> <script>alert(“Bad!”);</script>”</div> Which would let the script run. So wp_kses_post() is completely wrong … Read more

confused about sanitize_email after is_email [duplicate]

Regarding the edited question, here’s another old Q&A, which might actually be a better reference, Should I sanitize an email address before passing it to the is_email() function?, especially @kaiser’s answer. And regarding kaiser’s Funny sidefact now as I had a look at the sources for both functions (is_email(), sanitize_email()), they are indeed basically the … Read more

allow only lowercase user registrations

The filter validate_username sends and expects a boolean value, not a string. Hook into sanitize_user and use mb_strtolower(). Sample code, not tested: add_filter( ‘sanitize_user’, ‘wpse_83689_lower_case_user_name’ ); function wpse_83689_lower_case_user_name( $name ) { // might be turned off if ( function_exists( ‘mb_strtolower’ ) ) return mb_strtolower( $name ); return strtolower( $name ); }