Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [validation]

The tag has no usage guidance.

0
votes
1answer
16 views

Using $wpdb | checking entered email against existing emails in db

Without ranting too much, here is my snippet: if (empty($_POST["email"])) { $emailErr = "Email is required"; } else { $email = test_input($_POST["email"]); // check if e-mail address is ...
0
votes
1answer
69 views

Validate custom fields before save using WordPress Rest API

I want to add custom validation to post(custom post type) before it save into the WordPress. I am using the Rest API to insert the post to custom post type. What I need is the fields which I created ...
1
vote
1answer
39 views

wooCommerce checkout page State / County (optional) validate not working

wooCommerce checkout page State / County (optional) validate not working that is my added code add_filter(‘thwcfd_State_field_override_required’,’__return_true’); any idea for how to add ...
0
votes
2answers
39 views

Assignments must be the first block of code on a line Validation Error on Travis

Travis is giving me ~ Assignments must be the first block of code on a line for this specific line of code: $validate_string = $pf_param_string = substr( $pf_param_string, 0, - 1 ); It seems fine ...
5
votes
1answer
508 views

Validation error: Extending Gutenberg gallery block

I am trying to extend the Gutenberg core/gallery block to add some new functionality to my image gallery on the frontend. I have created a separate plugin to handle this task. I have registered my ...
1
vote
0answers
398 views

jquery.validation.js is not working in woocommerce checkout page form

jQuery("#woocommerce_checkout_form").validate({ highlight: function(element) { (jQuery(element).parent()).parent().addClass("woocommerce-invalid"); (jQuery(element)....
0
votes
0answers
72 views

Form validation and error message display

I have a custom HTML form on a page. I'd like to do some server-side validation. If the validation is successful, I'll process the request and wp_redirect to another page. If the validation fails, I ...
2
votes
1answer
64 views

Stop the form of beign submitted on “Save changes” custom option page

Using the Settings API of Wordpress i want to try cancel the submission of the options when the validation/sanitization fails. Registering the settings: register_setting( 'mysettingspage', '...
7
votes
1answer
271 views

Sanitize and data validation with apply_filters() function

Should we sanitize and validate the apply_filters() like the examples below? absint( apply_filters( 'slug_excerpt_length', 35 ) ); wp_kses_post( apply_filters( 'slug_excerpt_more', '…' ) );...
2
votes
1answer
325 views

Remove frameborder attribute from iframes

The W3C Validator outputs an error because Wordpress adds frameborder="0" to iframes. Also the Validator does not like the allow attribute. I found a similar question for Vimeo Videos: WordPress ...
1
vote
1answer
251 views

Error in Validate Field with ACF plugin in Wordpress

I have the following problem when I am validating a field with the Advanced Custom Fields plugin in wordpress. What happens is that the field is validated correctly but the error appears on a new page ...
1
vote
1answer
23 views

Do I have to have a nonce for a custom comment field?

im working on my comment section and I have added a custom field <input type="hidden" name="be_user_star_rating" id="be_user_star_rating" value="" /> Its value is beign set by Javascript. ...
-1
votes
1answer
200 views

WP Debug enabled Undefined index error in a widget

I have set WP debug to true, and I am getting error message → Notice: Undefined index: tick_the_snippet_type <p> <input type="radio" <?php checked( $instance[ '...
1
vote
0answers
91 views

wp_remote_post - handling responses

I need to add a form to my WordPress site that will post its data to an external API without ever storing the form data in the mysql database. I also need to show components of the response from the ...
0
votes
0answers
229 views

phone number validation regex

i wanted to change the regex format in my file from cpanel where i found a code such as: case 'number': $res .= "<input type='text' name='$key-$i' id='$key-$i' pattern='[0-9]{12}' maxlength='...
0
votes
1answer
30 views

Is it necessary to do validation again when retrieving data from database?

I do validation when saving data to database like following: $data = validate($data); update_post_meta($post_id, 'my_post_meta', $data); The question is, do I need to do validation again when read ...
0
votes
1answer
506 views

WordPress REST API validation

I'd like to validate the data sent to my end point. https://www.shawnhooper.ca/2017/02/15/wp-rest-secrets-found-reading-core-code/ This post referenced the undocumented validation options. I have got ...
2
votes
0answers
1k views

Remove type attribute from script added by wp_localize_script

How can I remove type attributes from all scripts added by wp_localize_script ? Have the same problem with W3C validation as described here - Remove type attribute from script and style tags added by ...
0
votes
1answer
400 views

Jquery Validation Engine with Conatct Form 7

I am using contact form 7 and it's working with basic validations. But i have to do some advanced validation. So i have to use https://github.com/posabsolute/jQuery-Validation-Engine. How can i use ...
0
votes
1answer
357 views

Add file upload with validation to custom form

I have a custom contact form page that I am trying to add an upload field that validates filesize and filetype. Before adding the validation everything worked. <?php /* Template ...
5
votes
1answer
111 views

Shortcode putting html such as <img>

$atts = shortcode_atts( array( 'path' => 'https://s.w.org/about/images/logos/wordpress-logo-simplified-rgb.png' ), $atts); The above is a part of the shortcode. In Wordpress text ...
8
votes
7answers
27k views

Remove type attribute from script and style tags added by WordPress

Warning: The type attribute is unnecessary for JavaScript resources. From line 10, column 146; to line 10, column 176 feed/" /> <script type="text/javascript">window Warning: The ...
0
votes
1answer
41 views

Passing form data on submit

In my sanitizing script, prior to using the POST Request method to submit this data, I have the following for my textarea input field named 'contact_msg': if($_POST['contact_msg'] != ''){ $...
0
votes
1answer
56 views

How to escape multiple attribute at once in WordPress?

I'm developing a WordPress theme and trying to escaping group of attribute at once that store with a variable. <?php $attributes = array(); $classes = array( 'header-section' ); if ( true == ...
0
votes
1answer
92 views

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 ...
0
votes
1answer
222 views

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 ...
0
votes
0answers
39 views

Form Sanitization and Validation

Already asked this on Code Review but no answer there so that's why i'm trying here. I'm kinda new to form sanitization and validation. If someone could look at my code and tell me where i could do ...
-1
votes
1answer
333 views

How to use esc_attr__() function properly to translate a variable that contains string?

I am trying to develop a theme and trying to escape a string using esc_attr__() fuction. Here is how I implemented it. $title = stoic_get_the_site_title(); echo esc_attr__($title, 'stoic'); But ...
1
vote
1answer
198 views

Validation Function for URL in plugin

if ( cpmb_is_valid_mp3( $_FILES['video-url']['name'] ) ) { $response = wp_upload_bits( $_FILES['video-url']['name'], null, file_get_contents( $_FILES['video-url']['tmp_name'] ) ); ...
-1
votes
1answer
5k views

How to do Conact form 7 name field validation? [closed]

I am using contact-form-7 plugin, where i have created name field as Name. The name field is accepting text and number too. But my requirement is that name field should not start from number so how i ...
4
votes
1answer
421 views

edit profile validation refreshes all field if missing wordpress

In the edit profile section whenever I'm updating a field and if for example I've missed one required field (NickName) and changed the email address to a new one, the WordPress validation will ...
0
votes
0answers
1k views

Contact Form 7: Make field required after checkbox is checked

I have a telephone field in Contact Form 7 as follows: [tel Phone id:Phone] and a checkbox that for users to optionally choose to be called back: [checkbox Callback id:Callback "Rückruf gewünscht"] ...
0
votes
2answers
618 views

Sanitizing text fields in array

I tried this code to create some meta boxes is all working fine, the problem I am facing is how to sanitize the text fields and update post meta function Print_price_fileds($cnt, $p = null) { ...
1
vote
1answer
155 views

Permit Login if table row exists

I am using the "authenticate" filter hook within the WordPress codex to adjust the validation script of the WordPress Login page. What I need to do is create a query to a separate table to see if ...
0
votes
0answers
49 views

Getting an weird symbol instead of “ ã ”

In the backoffice I'm getting an weird symbol with ? instead of ã. I've tried to validate this with esc_attr(), sanitize_text_field(), etc but nothing works. How can I solve it? This is the code: <...
0
votes
2answers
2k views

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"...
0
votes
1answer
376 views

Required radio button does not validate in form, when clicked through Javascript/jQuery

I have a radio button that selects a dealer in my checkout. I need this button to automatically be checked for the user - however, no matter what I do, the radio button still needs to be clicked to ...
0
votes
0answers
42 views

Validating Error with submit button

I really need your help.. I am tryin like 3 days now to change the first pic and make it like the 3rd one. I did it but when Iremove depoarture day the enquire button doesnt work and dont get the form(...
0
votes
1answer
223 views

Custom HTML form using PHP - help with ajax/username validation

I currently have a working registration form I created on my page. It's an HTML form and I coded PHP to have it create the user in our WP_user table and email us with info from the form. The PHP is in ...
0
votes
1answer
565 views

Allow users to register on multisite through WooCommerce using the same email address

I'm working on setting up a multisite environment, and have run into the possibility of a user trying to register on the sub-site with the same email address they've used on the main site. I've found ...
1
vote
2answers
27 views

What esc_ to use to validate this?

I tired esc_url but it doesn't work. if ( $power_by ) { ?> <div class="sponsor-credits"> <span class="sponsor-credits__label">Powered by </span> ...
1
vote
1answer
79 views

Prevent invalid or empty values from being saved to the database and retain the form field values upon error

I'm using the Settings API to save the settings of my plugin. I want a positive integer value from the settings field. register_setting( $option_group, $option_name . '_number', '...
-1
votes
1answer
1k views

Custom Registration and Login Forms with reCaptcha 2 Validation

I've read all the posts at stackoverflow and wordpress stackexchange, and none of the topics on using Google reCaptcha 2 have given me information on how to validate reCaptcha on both custom wordpress ...
1
vote
1answer
79 views

Does balanceTags() provide any escaping / protection?

I'm just getting into WordPress and keep seeing sample code with balanceTags() used when echoing out a variable. Am I right in thinking it does nothing in terms of output validation? Thank you
1
vote
1answer
58 views

Who is responsible for data sanitization in WordPress development?

I am studying how to write more secure WordPress code by implementing validation, sanitization and data escaping wherever necessary. Validation and escaping makes perfect sense, but I am a little ...
0
votes
2answers
400 views

Best Practice for Validating and Sanitizing Data

I developed a plugin which processes data following user input into a number of forms on the front end. The field types within the forms and the data input varies significantly. To process the data, ...
0
votes
1answer
39 views

Restrict certain roles registrations by domain

I'm really stumped on this one. I have figured out how allow registration from certain email domains. However, I only want to restrict one user type. For example 'ROLE1' can register with any email ...
0
votes
1answer
130 views

media_handle_upload on mix form fields (not required file input)

I collaborate with the development of the theme Odin Framework, which has several classes that leverage the launch of a site from scratch. Among them, we have the abstract-front-end-form.php (link to ...
4
votes
2answers
131 views

What is the best practice for escaping data URIs?

Usually, you would use esc_url() to escape a URL before displaying it. If that 'URL' is a data URI (eg. 'data:image/svg+xml;base64,...'), it will be trimmed blank by esc_url(). The Codex page on Data ...
0
votes
1answer
361 views

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

I have a gravity form that I want to, only allow people submit if they enter a specific code from a possible list of 3. Example codes XH6D 8U2A L9D3 If a user enters XH6D into the form, the form ...