Articles of validation

Disable woocommerce PLACE ORDER button if user selected products that are not available for international delivery

In my woocommerce site, I list both products that are available for shipping to India as well as International destinations. Am assigning a only-india shipping class to certain products so as to mark them as available for India only. Now am trying to add validation in the Checkout page so as to prevent users from […]

Validate form in functions.php, send errors back to template

I have a form in a template that upon submission should be validated, and any errors should be displayed, and if no errors, insert the data into the database. I’m new to wordpress, but my idea was that maybe an “action” could solve this. So I have a function in functions.php: function signup_validate_insert($errors){ if (isset($_POST[‘submit_msg’])) […]

jQuery plugin not loading

I am trying to use the below function to enquue 2 scripts (one internal, one external). The internal one (‘custom_script’) is working, but the 2nd one (‘formValidation’) isn’t (I get a ‘validate() is not a function’ error). The validation one is an external link to the script. Am I doing it wrong? If so, what’s […]

Make post_content and other custom fields required

What’s the best way to set the required atribute on html forms in wordpress, for instance I would like post-content to be required, so this code need to be changed: <textarea class=”wp-editor-area” style=”height: 300px; margin-top: 37px;” autocomplete=”off” cols=”40″ name=”content” id=”content”></textarea> To appear like this: <textarea required class=”wp-editor-area” style=”height: 300px; margin-top: 37px;” autocomplete=”off” cols=”40″ name=”content” id=”content”></textarea> […]

How do I sanitize the str_replace function in javascript variables

I have the following code in the javascript which outputs the date(s). With backslash for that, I’m replacing those strings with the str_replace to remove backslash, but I can’t sanitize that using any escaping function like esc_js. Stored Days Array array (size=2) 0 => string ‘4/7/2018’ (length=8) 1 => string ’11/18/2017′(length=10) The code var disabledDays […]

How WordPress sanitizes post content on save? Or it doesn't?

Does WordPress apply any kind of data sanitization for its post content when saving it from admin area? (like stripping <script> tags) Or all it does is checks for some user capability (like current_user_can(‘edit_posts’)? I’m asking, because I’m making widget plugin: It allows to add or edit HTML content which will be later shown of […]

How to make custom comment fields required and message field not required

I have a comment form that has name, email, brief, detailed and rating fields. The name, email, brief and rating need to be required, but the latter two are custom fields and I can only make them required through Javascript, but want to add proper WordPress/PHP validation to those fields. The detailed field is actually […]

Remember form field values with page navigation

I have a form on a page template that controls which posts show up on the page and how those posts are ordered. You can see what I mean here: http://www.theseattlevine.com/the-vine The questions I have is, how do I get the form to “remember” the selected values when the user uses the pagination at the […]

allow only lowercase user registrations

I’m trying to get allow only lowercase usernames are valid usernames in my wordpress blog. I managed to write a function but it does not seem to work. add_filter(‘validate_username’ , ‘simple_user’, 1, 2); function simple_user($valid, $username ) { if (preg_match(“/[a-z0-9]+/”, $username)) { // there are spaces return $valid=false; } return $valid; } Any ideas with […]

Ajax Validation for reCaptcha

Background I have a registration form that validates with AJAX using jQuery Validation Engine. The form was created using Theme My Login and contains reCaptcha which I implemented using WP-reCAPTCHA. Just like the rest of the fields, I needed to validate reCaptcha using AJAX as well, that is, without refreshing the whole page. So far […]