After some research, I altered my approach to validate the meta values in the following way:
- Create a new meta key(for post type) to store the validation (0 and 1).
- Initiate it with 0.
- This need not be kept/shown in the meta form.
- While saving the meta fields (preferably within
save_post
hook), set its value depending upon the validation. - Use this meta value to detect the validation status of the post. For example you can display/hide the post depending upon this value.
Related Posts:
- Add validation and error handling when saving custom fields?
- Using get_post_meta with new_to_publish
- Correct Approach for Validating Custom Field Input
- How to store the value of a custom field dropdown select for post referencing?
- Get updated meta data after save_post hook
- Check before publishing, if already exist post with current custom field value
- How to make custom comment fields required and message field not required
- How to reload the role specific registration form on validation errors?
- Check if the value of a field has changed on save_post
- How to validate custom field on lost password form before the user id field?
- Validate data on attachment_fields_to_save
- Send email with custom fields after new draft is saved or new post published
- Get updated meta value after post update or published (custom post type) using hook
- custom-meta-box checkboxes from loop won’t save
- Saving Custom Field Data before Publish
- Show user info in a hovercard [closed]
- Allow only one post with specific meta value
- Warn user that data may be lost for custom pages
- What is the proper way to add a required field to a post type? [duplicate]
- Custom metabox not displaying multiselect data in edit mode
- How to validate select field in post meta?
- How to add fields in custom registration form, validate it and aave to db? [closed]
- frontend submit post jQuery clone row won’t save
- Can wp_insert_post_data filter be used to save custom field data?
- How to validation for sanitize_URL?
- Exclude URL’s from sanitize_html_classes
- Making custom meta box required (with error message if not filled in) on Gutenberg
- Use value from ACF to populate other fields
- update a custom field with the value of another existing custom field
- Post meta data not showing in frontend, until hitting ‘update’ button
- How to format the various types of custom fields?
- Why WordPress takes time to make request to save post?
- Saving metadata of related post on save_post
- Validating custom meta boxes with jQuery results in posts being saved as draft instead of published post
- added a meta box to post however when saving menu while debug on throws a warning
- Change post status by custom fields
- Multiple triggers when publishing, saving or updating a post in WordPress
- Custom fields empty after refreshing page
- Advanced Custom Fields: how do I check to see if a value is set in an field? [closed]
- WP_Query – Order results by meta value
- Add filter menu to admin list of posts (of custom type) to filter posts by custom field values
- getting all values for a custom field key (cross-post)
- How to add a custom field in the advanced menu properties?
- Custom query with orderby meta_value of custom field
- How to filter post listing (in WP dashboard posts listing) using a custom field (search functionality)?
- Using meta query (‘meta_query’) with a search query (‘s’)
- Can I exclude a post by meta key using pre_get_posts function?
- Query to sort a list by meta key first (if it exists), and show remaining posts without meta key ordered by title
- Check for update vs new post on save_post action
- Prevent post from being published if custom fields not filled
- Show Custom Fields in Quick Edit
- How to avoid infinite loop in save_post callback
- Where are custom field values stored in the database
- Validating Custom Meta Box Values & Required Fields
- Max length of meta_value
- Add custom fields to wp native gallery settings
- How to fix missing custom fields after upgrading to WordPress 4.8.1?
- don’t publish custom post type post if a meta data field isn’t valid
- How to enable custom fields for pages (if not a bad practice)?
- How can I add extra attribute in the ‘Page Attribute’ section in wp-admin for pages?
- Is there a way to set default custom fields when creating a post?
- Custom post meta field effect on the performance on the post
- How to get custom post meta using REST API
- Custom field/meta populated by dropdown of existing posts?
- Difference between meta keys with _ and without _ [duplicate]
- Is there any action filter/hook for validating a custom field before publishing the post?
- Remove Dimension from wp_get_attachment_image
- Orderby meta_value only returns posts that have existing meta_key
- Underscores in custom fields
- What is the index [0] for on post meta fields?
- What is “meta_input” parameter in wp_insert_post() used for?
- Query Posts or Get Posts by custom fields, possible?
- How to validate custom fields in custom post type?
- How to enable revisions for post meta data?
- Sortable Custom Columns in User Panel (users.php)?
- Any way to add custom options to Gallery Settings?
- The “_encloseme” Meta-Key Conundrum
- ORDER BY custom field value
- Individual Widgets per Page
- Add subtitle to Woocommerce product title
- Best way to programmatically remove a category/term from a post
- Importing data for advanced custom fields plugin?
- Gutenberg add a custom metabox to default blocks
- SQL Query to copy value of a meta_key into another meta_key
- ‘Preview Changes’ for custom meta boxes?
- Adding a custom field to the site identity menu
- Using TinyMce with textareas in meta boxes on custom post types
- wordpress function to change post status [duplicate]
- Filter WP_Query for posts having a certain meta-value
- How to correctly call custom field dates into a posts_where filter using SQL statements
- Is there a way to get protected meta fields through any of the available built-in WordPress APIs? (xmlrpc, wp-json)
- Add a Jquery Datepicker to custom field in post edit
- add meta box – custom field : which to choose?
- Why doesn’t wp_update_post() update the post_status field?
- Preserving line breaks when saving and displaying custom fields data
- How to return Meta data from the REST API?
- Advanced Custom Fields – Get custom fields from parent page
- Can I query custom meta data through WP_Query
- Add custom field to the archive page?
- Saving custom data for each user