Questions tagged [validation]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
1 answer
26 views

What is the correct way of validating running code when a particular role accesses a screen?

I'd like to run a series of actions if a particular role accesses a specific screen. For example, if( is_user_logged_in() && ! current_user_can( 'activate_plugins' ) ) { if( isset( $...
Ryan's user avatar
  • 53
0 votes
0 answers
181 views

Validate a custom form with js and php

I would please need help with the following: I have a form in my WP Plugin, that is validated with js, which works fine, Then I want to validate it using php, display the errors on the form and after ...
gladys's user avatar
  • 11
0 votes
1 answer
34 views

Gallery Block in template, validation fails after adding column number

I have set up a template in a block like so: const TEMPLATE = ['core/spacer', {height: '100px'}], ['core/gallery', {templateLock: 'false', columns: 2}] ; const ...
Fou Rorty's user avatar
0 votes
1 answer
48 views

how to sanitizing $_POST with the correct way?

I am trying to sanitize and validate and escape this code? $positions = $_POST['positions']; foreach ($positions as $key => $position) { $id = sanitize_text_field($position[0]); ...
crazybuilding's user avatar
0 votes
1 answer
152 views

Set post status to draft after validating post meta values in save_post hook

I have some custom meta values to a custom post type ('event'). The custom post type is displayed in the admin and the custom meta fields are appearing fine. I am using save_post_{$post->post_type} ...
sariDon's user avatar
  • 255
1 vote
2 answers
542 views

Display notice in block editor after wp_insert_post_data hook

I have a custom post type which checks and validates some (custom) meta fields added with it upon publishing. I am using wp_insert_post_data for the purpose: public function __construct() { $this-&...
sariDon's user avatar
  • 255
0 votes
1 answer
26 views

How to add verification on email address change?

I have custom form for changing email address and it's working perfectly. However, i realized that i have to add some precautions to prevent my users from using invalid or email address they do not ...
CruzZ's user avatar
  • 11
0 votes
1 answer
119 views

why is kses removing semicolon from inline style?

I have a validation function that uses wp_kses, and it works as expected to remove code from the input if it is relatively simple code HOWEVER using kses is also removing semicolons from inline styles....
ubsd's user avatar
  • 3
3 votes
0 answers
169 views

Is there a way to prevent wp_head from outputting self-closing tags?

I'm a beginner in WP development, so maybe I'm missing something obvious. Is there a way to prevent wp_head from outputting self-closing tags? Here are two example lines taken from my website: <...
Kerans's user avatar
  • 31
1 vote
1 answer
182 views

oneOf two possible objects in WP REST API?

I'm trying to define an endpoint that accepts two possible objects upon input, and currently tried to do so via: 'args' => [ 'type' => 'object',...
DevelJoe's user avatar
  • 487
0 votes
0 answers
242 views

WP Rest API - Change response status code for failed validation request

I have created a new route with this code: register_rest_route( 'namespace', 'some-route', [ 'methods' => WP_REST_Server::CREATABLE, 'callback' ...
djanym's user avatar
  • 125
3 votes
0 answers
84 views

Custom block Block Validation failure w/ deprecation declared

I am running into a custom block validation issue from some markup changes in the block html. I am wondering what I am missing about the deprecation as it's being hit but not validating the old markup ...
user2843140's user avatar
0 votes
1 answer
37 views

Block pattern conflict with custom block

I have created a custom block named testimonials and saved it as a pattern. The problem is when I make some modifications to the block save function it doesn't match with the pattern anymore and I get ...
Alexander's user avatar
  • 133
3 votes
0 answers
352 views

Custom Block - save.js function not saving attributes

I'm trying to get just a basic custom block displaying in the editor and saving. I've followed multiple tutorials and I keep getting the same result. No matter how simple my block is, whenever I add a ...
Ryan H's user avatar
  • 31
0 votes
1 answer
43 views

Contact form - problem with displaying message about sent mail

I'm trying to develop a contact form for a language school website that runs on Wordpress. Disclaimer: I'm about 6 months into coding, so please forgive me for being new to this. I'm developing my own ...
ScorpVisual's user avatar
0 votes
1 answer
453 views

Hook before user is created and make some custom validation

I try to hook in user creation process in admin dashboard /wp/wp-admin/user-new.php to make some custom validation on data with the following hook, but the hook is not executed on form submit. What ...
fefe's user avatar
  • 844
0 votes
1 answer
824 views

Contact Form 7 Wordpress, checking a few fields, if empty then invalid

Could someone help me to solve the problem. I would like the system work like bellow. If both fields are empty = invalid. If any of the fields is completed = valid add_filter('wpcf7_validate_text', '...
Robert's user avatar
  • 1
0 votes
0 answers
702 views

How to add custom regex validation to WPForms password field

I'm using WPForms Pro and I'd like to add custom requirements to the password field on a form. I know that the password field has a password strength requirement setting, but I have specific rules I'd ...
Sidewinder's user avatar
1 vote
0 answers
29 views

Can I use custom CSS and js plugin to put JavaScript in to validate my forms

I would like to put some front-end JavaScript validation to my forms, but was wondering, if I can put the JavaScript for the field validations in the custom CSS and js plugin, or do I need a specific ...
Spencer Halstead's user avatar
0 votes
1 answer
183 views

Add Server Side validation in Ajax mail form

I'm building a form that takes fields values and send them via wp_mail to the post author. It works, but I want to add a server side validation to improve security. I don't know where to add my ...
Silvia Malavasi's user avatar
1 vote
1 answer
439 views

Settings API - sanitize_callback is not called and it leads to an incorrect behavior

I am in the process of creating some options / the options page for my plugin. In the context of this I have only added two checkboxes so far to store boolean values. The creation, display on the page ...
Sven Rösser's user avatar
0 votes
1 answer
639 views

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

I use a WP theme with a custom registration form. I want to add two fields to it (for phone number and company name). What to add to the php file of the form and what to the function file of theme ...
Vladimir Dimitrow's user avatar
0 votes
1 answer
380 views

How do I change the text content of a div for a comment validation error message?

My comment form has validation so that when a user tries to post a blank comment, it currently shows the "This field is required" message under the comment box. How do I change the message ...
Scarlett's user avatar
0 votes
0 answers
355 views

Making custom meta box required (with error message if not filled in) on Gutenberg

<input required name="myName" type="text" value="<?php echo $myValue; ?>" class="regular-text"> Does not produce an error message if the field is ...
Drewdavid's user avatar
  • 189
1 vote
0 answers
1k views

How do I add a 5 digit ZIP code validation to a Contact7 form?

I have an address form generated via Contact7. I need to validate there is a 5 digit zip code. According to the docs, I came up with this function and placed it in my functions.php file add_filter( '...
david lee's user avatar
  • 131
1 vote
1 answer
1k views

ACF Custom validation message not showing up

I have two date fields where I want to make sure the "end date" is always later than the "start date". I added a validation function per ACF's documentation. It does fire, but the ...
geochanto's user avatar
  • 121
1 vote
1 answer
1k views

register_setting & add_settings_error validation issues with multiple fields

I've been trying to use the Settings API for the first time. I managed to piece together a working example but I'm stuck on how to make multiple input fields required. Right now I have an admin ...
Jon's user avatar
  • 351
1 vote
0 answers
183 views

rest_sanitize_value_from_schema doesn't sanitize string

This is a part of a simplified piece of code. It accepts a JSON post, validates it against a schema and if ok, sanitize the JSON structure $schema = array( 'type' => 'object', ...
Roel Dekker's user avatar
1 vote
0 answers
174 views

How to remove role="navigation" from all nav elements?

I did a W3C validation of my wordpress website and I got several warnings like this: The navigation role is unnecessary for element nav. r">↩ <nav role="navigation" class="...
Celso Soares's user avatar
3 votes
1 answer
1k views

What is the proper way to validate and sanitize JSON response from REST API?

I have read the WordPress page about this but didn't find a solution. Here are my details: register rest route: register_rest_route( '/jwt-auth/v1', '/user', array( 'methods' ...
b3hr4d's user avatar
  • 141
0 votes
1 answer
65 views

Data Validation in wordpress

In my theme, i am grabbing user input with get_option() and according to that input i want to i want to declare a new variable and print in my single.php file. For example: <?php $...
Sahan's user avatar
  • 13
0 votes
1 answer
1k views

WordPress is creating nonce as a logged in user but verifying it incorrectly

I'm having trouble validating a nonce created with wp_create_nonce() inside a hidden input with the name nonce in an html form: <input type="hidden" name="nonce" value="<...
dewd's user avatar
  • 170
0 votes
1 answer
339 views

$ is not defined [duplicate]

I am learning WordPress and I am working on the contact us form. I am using jQuery validation. I am using the below code. function contact($atts){ $html='<form name="invite" id="...
user9437856's user avatar
0 votes
0 answers
524 views

What's the right way to validate JSON data coming from an AJAX POST request?

I'm building a little plugin with a send button: when clicked, the button calls (from the admin area) a rest api endpoint, passing JSON data through AJAX. Everything works very well and the callback ...
Life after Guest's user avatar
5 votes
1 answer
6k views

How to define a query parameter with REST API?

I'm trying to define a GET REST API endpoint with register_rest_route register_rest_route supports defining a URL parameter and it is documented at https://developer.wordpress.org/rest-api/extending-...
왕뚜껑's user avatar
0 votes
2 answers
2k views

Change pubDate in rss feed in another format

In the default wordpress rss feed the element <pubDate> is <pubDate><?php echo mysql2date( 'D, d M Y H:i:s +0000', get_post_time( 'Y-m-d H:i:s', true ), false ); ?></pubDate> ...
Honoluluman's user avatar
0 votes
0 answers
270 views

How to use third-party SendGrid Email Validation API in Gravity Forms?

Please let me know how to use SendGrid Email Validation API in Gravity Forms, using gform_field_validation filter? Gravity Forms filter example: add_filter( 'gform_field_validation', function ( $...
Parth Solanki's user avatar
0 votes
0 answers
171 views

Using built-in validation pop-up for custom fields

I am currently adding custom fields (by custom code) to the single product page in WooCommerce using the OceanWP theme. I was about to start custom validation to the fields when I noticed that the ...
Ewan Harold's user avatar
1 vote
2 answers
2k views

Is there a maximum length to user passwords?

In the database, the hashed password is stored in a field that can store up to 60 characters. My question: is there an upper character limit on the unhashed (user-chosen) passwords, or will the ...
Vörös Imi's user avatar
1 vote
1 answer
153 views

How to force field validation first, then its values saved durning edit profile?

I want to make validation of image during edit profile (wp-admin). My code for validation is: add_action( 'user_profile_update_errors', 'validate_steamid_field' , 10, 3); function ...
Tereska's user avatar
  • 31
0 votes
1 answer
752 views

How to save Checkbox-Options in Plugin Options Page

First of all: I am really a newbie. So I used a template for my options page and tried to customize it (works pretty good so far). About my plugin: It creates to post types and some meta boxes ...
BuddyHoli's user avatar
2 votes
2 answers
1k views

How to validate custom fields for a custom post type before insert?

I'd like to know how to validate custom fields and return error notice (if necessary) before a custom post type is inserted into the database. After a little research I found one similar question ...
Caio Mar's user avatar
  • 424
1 vote
1 answer
2k views

Form validation in WordPress Admin Panel

I am developing a WordPress plugin. In this regard I am gathering data from User using a Form via Wordpress Admin Panel. My code is like below <form method="post" name="newAddress" id="newAddress" ...
Foysal's user avatar
  • 417
1 vote
0 answers
15 views

Shrink down register_settings on Settings API

Instead of having so many function calls, is there a way that I can have one function call and all the fields under one section and then just call one section on the form? /** * Register each ...
Sema's user avatar
  • 21
0 votes
1 answer
87 views

confused about sanitize_email after is_email [duplicate]

Assume I have checked an email using is_email and the result is true, should I sanitize with sanitize_email? if yes, then why?
Makiomar's user avatar
  • 141
0 votes
1 answer
762 views

jQuery Validation plugin and Bootstrap 4 CSS classes

I'm using jQuery Validation plugin to validate a WordPress theme form. I'm using also Bootstrap 4 so I'd integrate the Bootstrap validation classes ("is-valid" and "is-invalid") with Validation plugin,...
user avatar
0 votes
0 answers
196 views

how to add security questions on wp-registration page and validate it

I wanted to validate security questions which show's on wp-login page validation is if answers are blank user cant login and if user register with 2 questions and admin change no. question show on ...
sunshine's user avatar
0 votes
0 answers
49 views

Data Validation & Sanitization for Big HTML Blocks

I'm developing a theme for Envato. Got Soft Reject because of issue typed in the question title. I created a 4 column widget area for my theme's footer. How can I sanitize the $output variable? Thank ...
Çağrı Özarpacı's user avatar
1 vote
1 answer
5k views

Wordpress-gutenberg - Block validation: Expected text

I am building a gutenberg block plugin and I got stuck on simple two-field structure. The issue is that the save function works properly but something is wrong with the edit function. When I reload ...
camilluskillus's user avatar
0 votes
1 answer
1k 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 ...
Jason Is My Name's user avatar

1
2 3 4 5